Create Strings of Column Id's
Great, That did the trick,thanks. regards Tom
jholtman wrote:
Is this what you want:
paste("-", paste(colnames(MyMatrix)[COL], collapse='-'), sep='')
[1] "-E-T" On 7/26/07, Tom.O <tom.olsson at dnbnor.com> wrote:
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.
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
View this message in context: http://www.nabble.com/Create-Strings-of-Column-Id%27s-tf4153354.html#a11859539 Sent from the R help mailing list archive at Nabble.com.