[R] create an object in a loop (v4)

2010-02-03 Thread Ivan Calandra
Hi everybody, I have just thought that it might help if I would provide a sample data set. I have attached it as a txt file (tab separated). Here is the modified code to fit this data set. library(WRS) file - read.table(file=file.choose(), header=T, sep=\t) seq.num- c(4,5)#column

Re: [R] create an object in a loop (v4)

2010-02-03 Thread jim holtman
For adding the 'names', put the data in a temporary first: for(i in 1:length(seq.num)) { k- seq.num[i] name.num- names(file)[k] temp - fac2list(file[,k], file[3]) names(temp) - levels(factor(file[[3]])) assign(paste(names(file)[3], name.num, sep=_), temp) }

Re: [R] create an object in a loop (v4)

2010-02-03 Thread Ivan Calandra
Great, thanks a lot! But I feel stupid... I didn't think about that easy solution. I wanted to change the names after... Anyway, it now works! Regards, Ivan Le 2/3/2010 14:22, jim holtman a écrit : For adding the 'names', put the data in a temporary first: for(i in 1:length(seq.num)) {