如果我的问题措辞不当,我很抱歉。
我在 r 工作,我有一个名为 Rent 的表,它可能看起来像这样:
Rent
ID Invoice Payment Paid Date
lucy 7/1/2018 100 9/1/2018
lucy 7/1/2018 150 10/1/2018
lucy 8/1/2018 100 11/1/2018
所以我想做的是,由于 Lucy 在 2018 年 7 月 1 日有两次付款,我想将它们组合在一起,然后将付款相加,并使用最新的付款日期。
到目前为止我所拥有的是
#to create a row that has the sum of the sales prices
Rent[,sum_late:=sum( as.numeric(("Sales Price"))),
by= c("Id","Invoice Date")]
#take the first of the unique IDs by the max paid date
head (SD,1) by=c("ID", "Invoice Date", max("Paid Date")
但是当我运行第一行时,所有 sum_late 列都是 N/A。我不确定我做错了什么。理想情况下,我想要一张这样的桌子。
Rent
ID Invoice Payment Paid Date
lucy 7/1/2018 250 10/1/2018
lucy 8/1/2018 100 11/1/2018
对不起,如果这是一个愚蠢的问题,我感谢任何帮助和反馈!谢谢大家的时间!!