[R] subset function

Petr Pikal petr.pikal at precheza.cz
Fri Feb 9 09:29:00 CET 2007


Hi

works for me

> zeta
  tepl tio2 al2o3  iep
1   60    1   3.5 5.65
2   60    1   2.0 5.00
3   60    0   3.5 5.30
4   60    0   2.0 4.65
5   40    1   3.5 5.20
6   40    1   2.0 4.85
7   40    0   3.5 5.70
8   40    0   2.0 5.25
> fit<-lm(iep~al2o3, data=zeta)
> fit<-lm(iep~al2o3, data=zeta, subset=tepl==60)

so you shall check what results from just subsetting your data e.g.

subset(in.mi01, C_X01=="Berlin")

HTH
Petr



On 9 Feb 2007 at 7:21, Simon P. Kempf wrote:

From:           	"Simon P. Kempf" <simon.kempf at web.de>
To:             	<r-help at stat.math.ethz.ch>
Date sent:      	Fri, 9 Feb 2007 07:21:00 +0100
Subject:        	[R] subset function

> Hello R-Users,
> 
> 
> 
> I have the following problem with the subset function:
> 
> 
> 
> See the following simple linear model. Here everything works fine:
> 
> 
> 
> >germany<-lm(RENT~AGE1, in.mi01)
> 
> 
> 
> However, if a use the same regression equation and only specify a
> subset, I get an error message:
> 
> 
> 
> > berlin<-lm(RENT~AGE1, in.mi01, subset=C_X01=="Berlin")
> 
> 
> 
> Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...)
> : 
> 
>         0 (non-NA) cases
> 
> 
> 
>  The datasets contains no missing values and for the city Berlin there
>  are
> 2200 observations.
> 
> 
> 
> > summary(in.mi01$C_X01)
> 
> Berlin               Düsseldorf           Frankfurt am Main    Hamburg
> Köln                 
> 
>                 2200                 1638                 2943
> 2068                  759 
> 
> Leipzig              Munich               Others              
> Stuttgart
> 
> 
>                  344                 1514                 7955
> 383
> 
> 
> 
> What am I doing wrong?
> 
> 
> 
> Thanks in advance for any help and suggestions,
> 
> 
> 
> Simon
> 
> 
> 
> 
> 
> 
>  [[alternative HTML version deleted]]
> 
> 

Petr Pikal
petr.pikal at precheza.cz



More information about the R-help mailing list