Is there a function in R that calculate the mean and median for a grouped data? For example, a survey shows the oil price outlook in the future. How can I calculate the mean/median? (Of course, I understand that the groups "below 80" and "above 110" must be defined more specifically) below 80 4 80-90 5 90-100 8 100-110 7 above 110 3 [[alternative HTML version deleted]]
David Winsemius
2013-May-08 04:02 UTC
[R] Calculates the mean/median from grouped data in R?
On May 7, 2013, at 8:40 PM, jpm miao wrote:> Is there a function in R that calculate the mean and median for a grouped > data? > For example, a survey shows the oil price outlook in the future. How can I > calculate the mean/median? > (Of course, I understand that the groups "below 80" and "above 110" must be > defined more specifically) > > below 80 4 80-90 5 90-100 8 100-110 7 above 110 3 >Why would all groups need to be defined more specifically? How do we know whether items in the 80-90 range are evenly distributed? .... could be 80, 81, 82, 84, 85 or all 89's. David Winsemius Alameda, CA, USA
see if this helps: library(actuar) data(gdental) # grouped data quantile(gdental) mean(gdental) Nuri On Wed, 8 May 2013, jpm miao wrote:> Is there a function in R that calculate the mean and median for a grouped > data? > For example, a survey shows the oil price outlook in the future. How can I > calculate the mean/median? > (Of course, I understand that the groups "below 80" and "above 110" must be > defined more specifically) > > below 80 4 80-90 5 90-100 8 100-110 7 above 110 3 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >