Skip to content
Prev 334603 / 398506 Next

How to manipulate this data?

Hi,

Try:
dat1<- read.table(text="name Value
? abc BXR
? abc DHH
? abc DHK
? def DHK
? def DSL
? ghi DSL
? abc DSM
? def DSM
? ghi DSM
? def DSS
? ghi DSS
? ghi DST
? abc DIW
? abc DIL
? ghi DIL",sep="",header=TRUE,stringsAsFactors=FALSE) 


aggregate(name~Value,data=dat1,paste,collapse=" ")
#or
library(plyr)
?ddply(dat1,.(Value),summarize, name=lapply(list(Value),paste,collapse=" "))
A.K.


Hi, 

I want my output to be like this: 
?Value 
BXR 
abc 

?DHH abc 

?DHK abc def 
?DSL def ghi 
?DSM abc def ghi ?DSS def ghi 
?DST ghi 

?DIW abc 

?DIL abc ghi 

My input dataset is this with colnames name and Value: 

?name Value ?abc BXR ?abc DHH ?abc DHK ?def DHK ?def DSL ?ghi DSL ?abc DSM 
def DSM ?ghi DSM ?def DSS ?ghi DSS ?ghi DST ?abc DIW ?abc DIL ?ghi DIL