R_列名が異なる二つのデータフレームを一つに統合 - RとLinuxと...

RとLinuxと...


R_列名が異なる二つのデータフレームを一つに統合

Rの備忘録

> test1 <- data.frame(doc = rep("test1",3) ,
                terms = c("A", "B", "C"), Freq = c(1,2,3))
> test2 <- data.frame(doc = rep("test2",3) ,
                terms = c("A", "B", "D"), Freq = c(4,5,6))
> new.df <- rbind(test1, test2)
> t(xtabs(Freq ~ ., data = new.df))
 
Link: Rの備忘録(1827d)
Last-modified: 2008-04-28 (月) 13:45:06 (3887d)