try something like: apply(tmp1[, ncol(tmp1):1], 1, paste, sep = ">")
I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Robert Lischke" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Tuesday, October 31, 2006 12:36 PM Subject: [R] generic pasting of strings > Hi there, > > is there a way to make the following code generic, so that i can > paste() > the columns in tmp1 depending on the dimensions given in embed()? > >> tmp1 <- embed(as.vector(shrinkTable$AOIname), dimension = 2); >> tmp1 > [,1] [,2] > [1,] "AOI4" "AOI1" > [2,] "AOI6" "AOI4" > [3,] "AOI4" "AOI6" >> tmp2 <- paste(tmp1[, 2], tmp1[, 1], sep = ">"); >> tmp2 > [1] "AOI1>AOI4" "AOI4>AOI6" "AOI6>AOI4" > > for dimension = 3 this would look like this: > >> tmp1 <- embed(as.vector(shrinkTable$AOIname), dimension = 3); >> tmp1 > [,1] [,2] [,3] > [1,] "AOI6" "AOI4" "AOI1" > [2,] "AOI4" "AOI6" "AOI4" >> tmp2 <- paste(tmp1[ ,3], tmp1[, 2], tmp1[, 1], sep = ">"); >> tmp2 > [1] "AOI1>AOI4>AOI6" "AOI4>AOI6>AOI4" > > Any ideas? > > Thanks for your help, > > > Robert Lischke > > ______________________________________________ > [email protected] 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. > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ______________________________________________ [email protected] 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.
