Re: [R] complex transformation of data

2011-01-21 Thread Den
That great! It's working! Thank you so much! It is a pure magic which makes my head spin. aggregate(.~ id, lapply(df, as.character), FUN = function(x)paste(sort(x), collapse = ''), na.action = na.pass) 1. help says: Note that ‘paste()’ coerces ‘NA_character_’, the character missing value, to ‘"NA

Re: [R] complex transformation of data

2011-01-21 Thread Den
Thank you for your efforts. Although it is still not working, it feels like getting closer and closer. id cycle1 cycle2 cycle3 1 1cmfcmfcmf 2 2mfcmfcmfc 3 3 acfNA acfNA NAcfm I really appreciate transformation from subsets ("c","m","f") to "cmf". That was critica

Re: [R] complex transformation of data

2011-01-21 Thread Henrique Dallazuanna
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 wrote: > > Thank you for your efforts. > Although it is still not working, it feels like getting closer and > closer

Re: [R] complex transformation of data

2011-01-21 Thread Den
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 1cmfcmfcmf 2 2mfcmfcmfc 3 3 cf cf cf (letter 'a' missing in df[

Re: [R] complex transformation of data

2011-01-21 Thread 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 wrote: > Try this: > > aggregate(.~ id, lapply(replace(df, is.na(df), ''), as.character), FUN = > paste, collapse = "", na.action = na.pass

Re: [R] complex transformation of data

2011-01-21 Thread Henrique Dallazuanna
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 wrote: > Dear Henrique > Thank you again for helping me > Unfortunately, your code seems not to be working > > > aggregate(.~ id, la

Re: [R] complex transformation of data

2011-01-21 Thread Henrique Dallazuanna
Try this: aggregate(.~ id, lapply(test, as.character), FUN = paste, collapse = "") On Fri, Jan 21, 2011 at 10:25 AM, Den wrote: > Dear [R] people > Could you please help with following data transformation. > Any suggestions, hints, references and even guessing on performing any > of the followi

Re: [R] complex transformation of data

2011-01-21 Thread Moritz Grenke
Hi Denis, #minimal example: test<-as.data.frame(list(id=c(1,1,1,2,2,2), cycle1=c("c", "m", "f", "m", "f", "c"))) #gettin your first cell of Result 1 paste(sort(test$cycle1[test$id==1]), collapse="") Hope this helps for the first task ... Moritz __ Moritz Grenke http://www

Re: [R] complex transformation of data

2011-01-21 Thread ONKELINX, Thierry
Denis, Have a look at paste(), aggregate(), ddply() (from the plyr package) and melt() and cast() (both from the reshape package). Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team