[R] Subset Question

Erik Iverson eriki at ccbr.umn.edu
Thu Feb 25 15:05:35 CET 2010


Chertudi wrote:
> Hello helpful R folks,
>
>    First off, please forgive my English.  Second, I'm new with R, I've
> searched the archives about subsets, and I haven't found quite the help I
> need.
>
> I'm currently analysing a population survey whose data set has about 15000
> households (the rows/observations) and 130 variables (the columns).  I've
> managed to import the set into R as a data.frame called eu08.  Now, I'm
> trying to look at all of the variables, but limited to one province in the
> "region" variable.  I think the provinces are factors, and the province of
> interest is labeled '3'.
> I've tried the following:
>
> region3=subset(eu08, region==3)
> --this simply strips all of the rows from the columns, and I know that about
> 4000 of the observations are specific to region 3.  So does putting the 3 as
> '3' and "3".
>
>  Any help would be greatly appreciate.
>
>   
Well, we don't know if it really is a factor.  You can determine that by 
doing...

class(eu08$region)

If it is a factor, then

levels(eu08$region)

should let you know what you can subset with. 

str(eu08) might also be good to look at...

Erik



More information about the R-help mailing list