I can't figure out how to calculate the mean for a subset of a column in R. My particular question is calculating "expenditures" for "age" 40+ and <40. I've tried
mean(expenditures[["age">=40]])
and gotten success, but
mean(expenditures[["age"<40]])
was not successful.
I am therefore stuck on this problem. I'll greatly appreciate any help on this seemingly simple question.