Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:03:46+00:00 2026-06-09T23:03:46+00:00

I have a vector like this : vec1 <- c(x1,x2,x3,x4) I have another vector

  • 0

I have a vector like this :

vec1 <- c("x1","x2","x3","x4")

I have another vector like this :

vec2 <- c("X1.RData","X2.RData","X3.RData","X4.RData")

What I am trying to do here is to load the RData files and then save them back with the same file names but the objects should be that of the vec1.

for (i in 1:length(vec1)){
vec1[i] <- get(load(vec2[i]))
save(vec1[i],file=vec2[i])
}

but its giving me error saying "incompatible types"
I also tried changing the class of the character objects like this :

class(vec1[i]) <- myclass

where myclass is class of the S4 type object.

Is there a way to do this in R ???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:03:48+00:00Added an answer on June 9, 2026 at 11:03 pm

    You will need to know the names of the objects in each of the .Rdata files. Object names are saved with the object contents and when accessed using load do not get assigned the names of the files in which they are stored. Furthermore, you would need to use assign in order to give those objects a new name. Assuming you had nothing else in the workspace at the time:

    Untested:

    for (i in 1:length(vec1)){ load(vec2[i])
       assign( vec1[i] , get( ls() )
       save(vec1[i],file=vec2[i])
       rm(list=ls(patt="^x.$") )
    }
    

    If you have other things in the workspace, then you really do need to know the names of the objects in those .Rdata files. (Although if you load()-ed these into an specific environment, you might be able to insulate the process from the rest of your workspace/)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a vector in R that looks like this: dat <- c(TRUE, TRUE,
I have a vector, v3, that looks like this: v3 <- matrix(c(1,1,3,3,2,2, 2,3,1,2,3,1, 3,2,2,1,1,3),
I have a large nested vector that look like this: import Data.Vector let x
Assuming I have a function like this my_method(const vector<const T*> & param); I wonder
I have declared std::priority_queue like this. priority_queue < Aircraft, vector<Aircraft>, less<Aircraft> > *q; And
I have a vector like this : Sum<-c(24, 32, 40, 48, 56, 28, 36,
I have a 3D vector defined like this... std::vector<std::vector<std::list<Object*> > > m_objectTiles; I have
I have a vector that looks like this: mass<-c(-2, -6, -79, 31, -28, 198,
Have a vector of vectors that looks something like this 3 1 2 0
I have defined a vector like this in the header file class entry {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.