Just change the FUN function: aggregate(.~ id, lapply(df, as.character), FUN = function(x)paste(sort(x), collapse = ''), na.action = na.pass)
On Fri, Jan 21, 2011 at 6:27 PM, Den <d.kazakiew...@gmail.com> wrote: > > Thank you for your efforts. > Although it is still not working, it feels like getting closer and > closer. > > id cycle1 cycle2 cycle3 > 1 1 cmf cmf cmf > 2 2 mfc mfc mfc > 3 3 acfNA acfNA NAcfm > > I really appreciate transformation from subsets ("c","m","f") to "cmf". > That was critical for me. > Hopefully, I'll figure out the rest later with ddply from plyr package. > At least this is my idea for now. > > > > У ÐÑÑ, 21/01/2011 Ñ 18:00 -0200, Henrique Dallazuanna пÑÑа: > > correction: > > aggregate(.~ id, lapply(df, as.character), FUN = paste, collapse = "", > > na.action = na.pass) > > > > On Fri, Jan 21, 2011 at 5:56 PM, Henrique Dallazuanna > > <www...@gmail.com> wrote: > > Try this: > > > > aggregate(.~ id, lapply(replace(df, is.na(df), ''), > > as.character), FUN = paste, collapse = "", na.action = > > na.pass) > > > > > > > > On Fri, Jan 21, 2011 at 5:45 PM, Den <d.kazakiew...@gmail.com> > > wrote: > > Dear Henrique > > Thank you again for helping me > > Unfortunately, your code seems not to be working > > > > > aggregate(.~ id, lapply(df, as.character), FUN = > > paste, collapse = "") > > id cycle1 cycle2 cycle3 > > 1 1 cmf cmf cmf > > 2 2 mfc mfc mfc > > 3 3 cf cf cf > > > > (letter 'a' missing in df[3,c("cycle1",cycle2")] > > > > You suggested very interesting approach, however. > > Those '.~ id' and > > 'as.character' gave me hope for success. > > With very best regards > > Denis > > > > > > У ÐÑÑ, 21/01/2011 Ñ 14:16 -0200, Henrique Dallazuanna > > пÑÑа: > > > > > Try this: > > > > > > aggregate(.~ id, lapply(test, as.character), FUN = > > paste, collapse = > > > "") > > > > > > On Fri, Jan 21, 2011 at 10:25 AM, Den > > <d.kazakiew...@gmail.com> wrote: > > > Dear [R] people > > > Could you please help with following data > > transformation. > > > Any suggestions, hints, references and even > > guessing on > > > performing any > > > of the following steps are highly > > appreciated. Those > > > transformations are > > > crucial for my work. > > > > > > (n_, _n, j_, k_ signify numbers) > > > > > > SOURCE DATA: > > > id cycle1 cycle2 cycle3 ⦠> > cycle_n > > > 1 c c c c > > > 1 m m m m > > > 1 f f f f > > > 2 m m m NA > > > 2 f f f NA > > > 2 c c c NA > > > 3 a a NA NA > > > 3 c c c NA > > > 3 f f f NA > > > 3 NA NA m NA > > > ........................................... > > > > > > > > > > > > RESULT DATA1: > > > id cyc1 cyc2 cyc3 ⦠> > cyc_n > > > 1 cfm cfm cfm cfm > > > 2 cfm cfm cfm NA > > > 3 acf acf cfm NA > > > ........................................... > > > > > > > > > RESULT DATA2: > > > id treatment > > > 1 n_cfm > > > 2 j_cfm > > > 3 2acf->k_cfm > > > ................... > > > > > > > > > RESULT DATA3: > > > id regimen numOfCycles > > > 1 cfm n_ > > > 2 cfm j_ > > > 3 asf->cfm {2+k_} > > > ............................. > > > > > > > > > > > > Thank you > > > Denis > > > > > > > > ______________________________________________ > > > R-help@r-project.org 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. > > > > > > > > > > > > -- > > > Henrique Dallazuanna > > > Curitiba-Paraná-Brasil > > > 25° 25' 40" S 49° 16' 22" O > > > > > > > > > > > > > > -- > > Henrique Dallazuanna > > Curitiba-Paraná-Brasil > > 25° 25' 40" S 49° 16' 22" O > > > > > > > > > > -- > > Henrique Dallazuanna > > Curitiba-Paraná-Brasil > > 25° 25' 40" S 49° 16' 22" O > > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org 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.