[R] state.x77 dataset

peter dalgaard pdalgd at gmail.com
Wed Mar 9 22:52:47 CET 2011


On Mar 9, 2011, at 21:57 , Ista Zahn wrote:

> Hi Rob,
> I'm not sure exactly what state is, but this works:
> 
> 
> data(state)
> 
> head(state.x77) #or whatever


Actually, you don't even need data(state); state.* are available as lazy-loaded objects. However, if you do, you get copies of the objects in the global environment:

> data(state)
> ls()
[1] "state.abb"      "state.area"     "state.center"   "state.division"
[5] "state.name"     "state.region"   "state.x77"     

The basic issue is that in the original sources, datasets/data/state.R contains multiple state.foo objects. Without the lazy preloading, data() would look for data/state.* and read it using the appropriate method (for a .R file: executing it). So in particular, there is no state.x77.* but loading state.R creates state.x77. This structure is retained with the preloaded data. Specifically, the .readRDS function returns an object  which is a list of character vectors:

....
$sleep
[1] "sleep"

$stackloss
[1] "stack.loss" "stack.x"    "stackloss" 

$state
[1] "state.abb"      "state.area"     "state.center"   "state.division"
[5] "state.name"     "state.region"   "state.x77"     

$sunspot.month
[1] "sunspot.month"
....

and, ..... well, you probably get the point by now.

-pd

> 
> Best,
> Ista
> 
> 
> On Wed, Mar 9, 2011 at 3:45 PM,  <rbaer at atsu.edu> wrote:
>> I tried:
>>> data(state.x77)
>> Warning message:
>> In data(state.x77) : data set 'state.x77' not found
>> 
>> data(iris)  seems to work fine, but the other state datasets (which I haven’t every tried before) don’t seem to be available
>> on my windows 7 running R 2.12.2 installation.
>> 
>> ?state brings up the state help page page which suggest the dataset should still be there. In help there still seems to be a reference to state.x77, so I’m thinking it should be there.  When I do data() I find:
>> state.x77 (state)
>> 
>> which might suggest it is in a package named even though the heading of the menu says datasets in datasets.   I see no package named state unless I’m missing something.
>> 
>> Anyone know what’s going on?
>> 
>> Thanks,
>> 
>> Rob
>>        [[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.
>> 
>> 
> 
> 
> 
> -- 
> Ista Zahn
> Graduate student
> University of Rochester
> Department of Clinical and Social Psychology
> http://yourpsyche.org
> 
> ______________________________________________
> 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.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list