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 ???