[R] Create Strings of Column Id's

Tom.O tom.olsson at dnbnor.com
Thu Jul 26 20:29:07 CEST 2007


Does anyone know how this is don?

I have a large matrix where I extract specific columns into txt files for
further use. To be able to keep track of which txt files contain which
columns I want to name the filenames with the column Id's.

The most basic example would be to use an for() loop together with paste(),
but the result is blank. Not even NULL.

this is the concept of thecode i use:

for example

MyMatrix <- matrix(NA,ncol=4,nrow=1,dimnames=list(NULL,c("E","R","T","Y")))
COL <- c(1,3) # a vector of columns I want to extract,

Filename <- NULL # the starting variable, so I can use paste
Filename <- for(i in colnames(MyMatrix)[COL]) {paste(Filename,"-",i,sep="")}

The result is "-T", but I want it to be "-E-T"

Anyone have a clue?

Thanks Tom


-- 
View this message in context: http://www.nabble.com/Create-Strings-of-Column-Id%27s-tf4153354.html#a11816439
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list