John Kane
2006-Aug-21 18:00 UTC
[R] aggregate example : where is the state.region variable?
I was looking ?aggregate and ran the first example aggregate(state.x77, list(Region = state.region), mean) The variables in state.x77 appear to be :> state.x77Population Income Illiteracy Life Exp Murder HS Grad Frost Area Where is the "state.region" variable coming from?
Gabor Grothendieck
2006-Aug-21 18:34 UTC
[R] aggregate example : where is the state.region variable?
Its not part of state.x77. Its a completely separate variable. Try ls("package:datasets") and notice its in the list or try ?state.region and note that its a variable in datasets. On 8/21/06, John Kane <jrkrideau at yahoo.ca> wrote:> I was looking ?aggregate and ran the first example > > aggregate(state.x77, list(Region = state.region), > mean) > > The variables in state.x77 appear to be : > > state.x77 > Population Income Illiteracy Life Exp Murder HS Grad > Frost Area > > Where is the "state.region" variable coming from? > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
Prof Brian Ripley
2006-Aug-21 19:51 UTC
[R] aggregate example : where is the state.region variable?
On Mon, 21 Aug 2006, John Kane wrote:> I was looking ?aggregate and ran the first example > > aggregate(state.x77, list(Region = state.region), > mean) > > The variables in state.x77 appear to be : > > state.x77 > Population Income Illiteracy Life Exp Murder HS Grad > Frost Area > > Where is the "state.region" variable coming from?> find("state.region")[1] "package:datasets" Try ?state.region for more info. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Richard M. Heiberger
2006-Aug-22 13:53 UTC
[R] aggregate example : where is the state.region variable?
> there is > no factor in the dataset but why there is not one and > why a call to another dataset is totally opaque.The reason is purely historical. The state dataset is about 10 years older than the data.frame concept. At the time the state.* variables were constructed it was not possible to put numeric data and factor data into the same rectangular structure.
John Kane
2006-Aug-22 20:31 UTC
[R] aggregate example : where is the state.region variable?
--- "Richard M. Heiberger" <rmh at temple.edu> wrote:> > there is > > no factor in the dataset but why there is not one > and > > why a call to another dataset is totally opaque. > > The reason is purely historical. The state dataset > is about > 10 years older than the data.frame concept. At the > time the > state.* variables were constructed it was not > possible to put > numeric data and factor data into the same > rectangular structure.I see. So originally the example would have been more obvious. Thanks