[R] Question: how to build a subset to do separate calculations

Erik Iverson iverson at biostat.wisc.edu
Thu Jul 24 22:40:57 CEST 2008



Erik Iverson wrote:
> Spencer -
> 
> Spencer wrote:
>>
>> Dear R Experts,
>>
>> I am trying to create several subsets that I want to use as separate 
>> datasets. After separate subsets are created for each country, I want 
>> to do some calculations for each. I did the following:
>>
>> data <- data.frame(na.omit(read.spss("trial.sav")))
>>
>> attach (data)
> 
> You might not want to call it 'data' since 'data' is the name of a 
> function in base R.
> 
> Also, the usual advice is to avoid attaching data.frames to the search 
> path, for the exact reasons that happen to you below.
> 
>>
>> Netherlands <- subset(data, COUNTRY = "NETHERLANDS")
>> attach(Netherlands)
>>
>> But after this step, when I check the summary statistics for 
>> "Netherlands," what returns is the summary for the original dataset. 
> 

Actually, this might not make sense to me.  What do you mean 'check the 
summary statistics for Netherlands".

What command are you giving  to R to do that?



More information about the R-help mailing list