Name of member Allowance Type Expenditure Type Date Amount, £
Adam Afriyie Office running costs (IEP/AOE) Incidentals 07/03/2009 111.09
Adam Afriyie Office running costs (IEP/AOE) Incidentals 11/05/2009 111.09
Adam Afriyie Office running costs (IEP/AOE) Incidentals 11/05/2009 51.75
Adam Holloway Office running costs (IEP/AOE) Incidentals 10/01/2009 35
Adam Holloway Office running costs (IEP/AOE) Incidentals 10/01/2009 413.23
Adam Holloway Office running costs (IEP/AOE) Incidentals 10/01/2009 9.55
Adam Holloway Office running costs (IEP/AOE IT equipment 07/03/2009 890.01
Adam Holloway Communications Expenditure Publications 12/04/2009 1774
Adam Holloway Office running costs (IEP/AOE) Incidentals 12/08/2009 1.1
Adam Holloway Office running costs (IEP/AOE Incidentals 12/08/2009 64.31
Adam Holloway Office running costs (IEP/AOE) Incidentals 12/08/2009 64.31
嗨即时通讯新的R和新的编程。这是特定时间段内议员开支的一部分。我想小计每个议员的费用,我用另一个职位的代码计算小计在R
> aggregate(cbind(bsent, breturn, tsent, treturn, csales) ~ yname, data = foo,
+ FUN = sum)
并编辑它到我自己的情况。
我的代码:
expenses2 <- aggregate(cbind(Amount..Â.) ~ Name.of.member, data = expenses, FUN = sum)
现在虽然这个代码做一些汇总的数量不匹配。例如可以计算出Adam Afriyie的开支是273.93英镑,但是这个代码给出了12697的结果。我不知道这个数字代表什么。有人可以帮助我,告诉我什么我做错了吗?
预先感谢您
请不要在变量名中使用特殊符号。理论上R可以处理它们,但它们倾向于给出一些意外。另外,你不需要做cbind(Amount)〜Name.of.member,你可以做聚合(Amount,Name.of.member,data = expenses,FUN = sum)。尝试一下,看看你是否仍然有错误的号码 – 2010-12-02 16:36:13