[R] indexing a subset dataframe

Mandy Barron BarronM at landcareresearch.co.nz
Mon Apr 16 07:07:38 CEST 2007


Hello
I am having problems indexing a subset dataframe, which was created
as:
> waspsNoGV<-subset(wasps,site!="GV")

Fitting a linear model revealed some data points which had high
leverage, so I attempted to redo the regression without these data
points:
>wasps.lm<-lm(r~Nt,data=waspsNoGV[-c(61,69,142),])
which resulted in a "subscript out of bounds" error.

I'm pretty sure the problem is that the data points identified in the
regression as having high leverage were the row names carried over from
the original dataframe which had 150 rows, but when I try to remove data
point #142 from the subset dataframe this tries to reference by a
numerical index but there are only 130 data points in the subset
dataframe hence the "subscript out of bounds" message.  So I guess my
question is how do I reference the data points to drop from the
regression by name?

Thanks
Mandy
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
WARNING: This email and any attachments may be confidential ...{{dropped}}



More information about the R-help mailing list