标签:style 使用 sp 数据 bs 时间 line as nbsp
我们经常会遇到两个数据框拥有相同的时间或观测值,但这些列却不尽相同。处理的办法就是使用
merge(x, y ,by.x = ,by.y = ,all = ) 函数。
#合并
ID<-c(1,2,3,4)
name<-c("A","B","C","D")
score<-c(60,70,80,90)
student1<-data.frame(ID,name)
student2<-data.frame(ID,score)
total_student1<-merge(student1,student2,by="ID")
total_student1
#横向追加
ID<-c(1,2,3,4)
name<-c("A","B","C","D")
score<-c(60,70,80,90)
sex<-c("M","F","M","M")
student1<-data.frame(ID,name)
student2<-data.frame(score,sex)
total_student2<-cbind(student1,student2)
total_student2
#纵向追加
ID<-c(1,2,3,4)
name<-c("A","B","C","D")
student1<-data.frame(ID,name)
ID<-c(5,6,7,8)
name<-c("E","F","G","H")
student2<-data.frame(ID,name)
total_student3<-rbind(student1,student2)
total_student3
R语言数据合并使用merge数据追加使用rbind和cbind
标签:style 使用 sp 数据 bs 时间 line as nbsp
原文地址:http://www.cnblogs.com/wangwp/p/4089191.html