[R] table, xyplot, names, & loops

Daniel Malter daniel at umd.edu
Tue Aug 25 19:44:18 CEST 2009

Just plotting the mean is not very informative (at least not more
informative than providing the same information in a table). If you want to
show some of the distributional properties of height for each Age_group x
City pair, try box-and-whisker plots ?bwplot

Imagine you have four age categories and five cities.


#Create a dependent variable
#Box whisker plot of Height by Age category for each City


cuncta stricte discussurus

-----Ursprüngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von w_poet
Gesendet: Tuesday, August 25, 2009 1:17 PM
An: r-help at r-project.org
Betreff: [R] table, xyplot, names, & loops

Hi R community,

I'm just starting out in R and have a basic question about xyplot and
tables. Suppose I had a table of data with the following names: Height,
Age_group, City. I'd like to plot mean Height vs Age_group for each City.

When I try to do the following:

> library(lattice)
> xyplot(mean(Height) ~ Age_group | City)

of course I get just one data point, the mean Height for all individuals.

I also tried constructing a new array with mean Height for each Age_group,
factored by City, but couldn't find any way of doing this without using

I'm sure there must be an elegant way of plotting this in R without
resorting to loops, but I can't find any hints in the online manuals.

Thanks for any tips~

View this message in context:
Sent from the R help mailing list archive at Nabble.com.

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list