Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Text 1 Text 2 Text 3 Text 4
- Bob Aba Abb Abc
- Robert Aba Abb Abc
- Fred Abd Abe Abf
- Martin Abg Abh Abi
- Text 1 Text 1a Text 2 Text 3 Text 4 Text 4a
- Bob Robert Aba Abb Abc Abd
- Fred NA Abd Abe Abf NA
- Martin NA Abg Abh Abi NA
- join=join(Data1, Data2, by = c('Text2'), type = "full", match = "all")
- MyDataAgg=aggregate(MyData, by=list(MyData$Text1), c)
- 1 -none- numeric
- 1 -none- numeric
- 2 -none- numeric
- $ Initials :List of 12505
- ..$ 1 : int 62
- ..$ 2 : int 310
- ..$ 3 : int 504
- do.call(plyr::rbind.fill,by(dat,list(dat$Text2,dat$Text3),
- function(d){
- ## change all other columns to a one row data.frame
- dd <- as.data.frame(as.list(rapply(d[,-c(2,3)],as.character)))
- ## the tricky part : add 1 to a name like Text1 to become Text11 ,
- ## this is import to join data.frames formed by by
- names(dd) <- gsub('(Text[0-9]$)','\11',names(dd))
- ## add key to to the row
- cbind(unique(d[,2:3]),dd)
- }))
- Text2 Text3 Text11 Text12 Text41 Text42
- 1 Aba Abb Bob Robert Abc Abd
- 2 Abd Abe Fred <NA> Abf <NA>
- 3 Abg Abh Martin <NA> Abi <NA>
Add Comment
Please, Sign In to add comment