This is a question for R-Help, not for R-devel by all means. You're lucky to get an answer, but please use the right channels in the future.
Cheers Joris On Tue, Oct 25, 2011 at 2:59 PM, RMSOPS <ricardosousa2...@clix.pt> wrote: > Hello Hans, > > Thanks for the reply, > > already changed and it gives me the following error > > Error in strsplit(line, ",*") : non-character argument > > #dataset read file > dataset > num<-nrow(dataset) > num > > #results >> dataset > A.B > 1 A,B,D > 2 F,G > 3 A,B,E > 4 F,G > 5 E,H > 6 A,E > 7 E,H > 8 A,B,C > 9 E,H >> num<-nrow(dataset) >> num > [1] 9 > > # > > > #read lines in the file > for(i in 1:num) > { > line<-dataset$Items[i] > print(line) > line<-dataset$Items[i] > * in.s <- strsplit(line, ', *')* > d <- sort (unique (unlist (in.s))) > > # Create the output matrix > output <- matrix (0, ncol = length (id), nrow = length (in.s)) > colNames (output) <- id > > for (i in seq_along (in.s)) { > output [i, unlist (in.s [[i]])] <- 1 > } > > the idea was to create a cycle matrix. > columns have the set of items (A ... B) > rows of the matrix (output) and the value 1 if present and 0 if the line is > not present. > > -- > View this message in context: > http://r.789695.n4.nabble.com/strsplit-convert-data-tp3932704p3936661.html > Sent from the R devel mailing list archive at Nabble.com. > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Mathematical Modelling, Statistics and Bio-Informatics tel : +32 9 264 59 87 joris.m...@ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel