student<-data.frame("Roll_No"=c("202","203","204","205","206","157"),"First_Name"=c("Shahrukh","Shakti","Shantanu","Shashank","Shirke","Abhinav"),"Last_Name"=c("Khan","Rawat","Verma","Sinha","Ganesh","MIshra"),"State"=c("MP","MP","UT","UP","Maharashtra","MP"))
elec<-data.frame("Roll"=c("202","203","204","205","206","157"),"Subjects"=c("Operations","Operations","Operations","Analytics","Marketing","Marketing"))
print(student)
print(elec)
kpv <- merge(student,elec,by.x = c("ROll_No"),by.y = c("ROll"))
答案 0 :(得分:1)
注意变量名称的区分大小写。在这里,我在合并调用中调整了它们:
student<-data.frame("Roll_No"=c("202","203","204","205","206","157"),"First_Name"=c("Shahrukh","Shakti","Shantanu","Shashank","Shirke","Abhinav"),"Last_Name"=c("Khan","Rawat","Verma","Sinha","Ganesh","MIshra"),"State"=c("MP","MP","UT","UP","Maharashtra","MP"))
elec<-data.frame("Roll"=c("202","203","204","205","206","157"),"Subjects"=c("Operations","Operations","Operations","Analytics","Marketing","Marketing"))
print(student)
print(elec)
kpv <- merge(student,elec,by.x = c("Roll_No"),by.y = c("Roll"))
kpv