Quantcast
Channel: merging data into existing column - Stack Overflow
Viewing all articles
Browse latest Browse all 3

merging data into existing column

$
0
0

I am trying to combine data from a dataframe into one value separated by && using merge (for no particular reason). Can someone explain what I am missing with this command?

news<-data.frame(c("2016-05-20","2016-05-19","2016-05-19"),c("x","y","z"))data<-data.frame(c("2016-05-20","2016-05-21","2016-05-22"),c(1,2,3))#bind news with the same date into value seperated by &&    news<-merge(news,by.x=news[,1])    #Error in as.data.frame(y) : argument "y" is missing, with no default

Bonus Question:

#merge news with data based on matching date    merge(news,data,by.x=news[,1],by.y=data[,1])    #Error in fix.by(by.x, x) : 'by' must specify uniquely valid columns

GOAL:

1                                  2016-05-20          1      x2                                  2016-05-19          NA     y && z3                                  2016-05-21          2      NA4                                  2016-05-22          3      NA

Viewing all articles
Browse latest Browse all 3

Trending Articles