Я вытащил этот текст в редактор.Затем сделали правильные имена заголовков и вернули вкладки, которые, по-видимому, были заменены пробелами и прочитали R, получая этот объект:
MPexp <- structure(list(Name_of_member = c("Adam Afriyie", "Adam Afriyie",
"Adam Afriyie", "Adam Holloway", "Adam Holloway", "Adam Holloway",
"Adam Holloway", "Adam Holloway", "Adam Holloway", "Adam Holloway",
"Adam Holloway"), Allowance_Type = c("Office running costs (IEP/AOE)",
"Office running costs (IEP/AOE)", "Office running costs (IEP/AOE)",
" Office running costs (IEP/AOE)", " Office running costs (IEP/AOE)",
" Office running costs (IEP/AOE)", " Office running costs (IEP/AOE",
" Communications Expenditure", " Office running costs (IEP/AOE)",
" Office running costs (IEP/AOE", " Office running costs (IEP/AOE)"
), Expenditure_Tyoe = c("Incidentals", "Incidentals", "Incidentals",
"Incidentals", "Incidentals", "Incidentals", "IT equipment",
"Publications", "Incidentals", "Incidentals", "Incidentals"),
Date = c("07/03/09", "11/05/09", "11/05/09", "10/01/09",
"10/01/09", "10/01/09", "07/03/09", "12/04/09", "12/08/09",
"12/08/09", "12/08/09"), Amount = c(111.09, 111.09, 51.75,
35, 413.23, 9.55, 890.01, 1774, 1.1, 64.31, 64.31)), .Names = c("Name_of_member",
"Allowance_Type", "Expenditure_Tyoe", "Date", "Amount"),
class = "data.frame", row.names = c(NA,
-11L))
Теперь это должно дать ожидаемый результат с агрегатом:
> aggregate(MPexp$Amount, MPexp["Name_of_member"], sum)
Name_of_member x
1 Adam Afriyie 273.93
2 Adam Holloway 3251.51
Повторное чтение вашего вопроса заставило меня понять, что вы используете aggregate.formula, так что это также сработает с этими данными:
> aggregate(Amount ~ Name_of_member, data=MPexp, FUN=sum)
Name_of_member Amount
1 Adam Afriyie 273.93
2 Adam Holloway 3251.51