根据多个条件和跨输入创建数据框 多个数据框,请事先提供帮助和感谢。
对于“ df1”中的每个名称,请使用“ df1”中的“表格”列来确定 其余三个数据帧(“ A”,“ B”或“ C”)中的哪一个进入。 然后从df1中的“数量”列中;确定多少 其他表中的观察结果应分配给每个表 个人。我喜欢进入适当的表格(A B或C),然后 提取数量列中指定的观测值数量。一世 想要将一个名为“已填充”的新列添加到新数据框中 被创建来跟踪发现了多少观察结果。
下面的数据框示例
Name<- c('John Doe','Peter Gynn','Jolie Hope', 'Al Tall', 'Ron Blue', 'Tom Plank')
Sheet<- c("A","A","B","C", "A","C")
startdate <- as.Date(c('2007-3-14','2010-11-1','2008-3-25','2007-3-14','2007-3-14','2007-3-14'))
Quantity<- c('3','2','7', '5', '4', '2')
Av<- c('5', '5', "10", '15','15', '20')
df1<- data.frame(Name, Sheet, startdate, Quantity,Av)
##
#sheet for Sheet A
info1<- c('1','2','3','4','5','6','7')
info2<- c("Aa","Ab","Bb","Cz", "Ad","A", "vd")
Av<- c('5', '5', '5', '5', '5', '5',"10")
A<- data.frame(info1, info2, Av)
#sheet for Sheet B
info1<- c('11','2','33','4','5','6','7','8','9','10')
info2<- c("A","A","B","C", "A","A","B","C", "A","B")
Av<- c('5', '10', '10', '10', "10", '10',"10", '15','15', "10")
B<- data.frame(info1, info2, Av)
#sheet for Sheet C
info1<- c('1','2','3','4','5','6','7','8','9','10')
info2<- c("A","A","B","C", "A","A","B","C", "A","B")
Av<- c( '10','15',"10", '15','1','15', '15', "10", '10','10')
C<-data.frame(info1, info2, Av)
结果应类似于以下数据框
谢谢