Skip to content
Prev 269724 / 398502 Next

Odp: {R} How to extract correctly from vector?

attempts to
the
Slightly better

 char <- paste("A",1:10,sep="")
data.frame(cbind(X1=1,Y1=1:10,X2=1,Y2=1:10,X3=1,Y3=1:10,X4=1,Y4=1:10,X5=1,Y5
One right parentheses more.
Maybe you wanted

x <- paste("X",1:10,sep="")
y <- paste("Y",1:10,sep="")
I would use list.

lll<- vector(mode="list", 10)
names(lll) <- char
for(k in 1:10) lll[[k]] <- d[,c(x[k],y[k])]

instead of many An objects you have one object with names An and you can 
easily subset it.

lll[[1]]
lll[["A5"]]
nam <- paste("test",1:10,sep="")
So the same applies here

lll<- vector(mode="list", 10)
names(lll) <- char
for (i in 1:10) lll[[i]] <- as.ltraj(xy=char[i],date=DATE,...)

However I do not know as.ltraj which may require different input of 
parameters.

Anyway in this case are lists by my opinion the only way to be able to 
handle such things smoothly and without much headache.

Regards
Petr
the
to
than
term
am
http://www.R-project.org/posting-guide.html