Re: [R] subsetting a dataframe

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Tue, 04 Mar 2008 14:57:36 +0100

try this:

Minus127 <- ShortLavin[!row.names(ShortLavin) %in% "127", ]

I hope it helps.

Best,
Dimitris



Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm

> windows XP
> R 2.6.0
>
> I am having problems deleting a row from a data frame. I create my
> dataframe by subsetting a larger dataframe:
>
> ShortLavin<-Lavin[Lavin[,"Site"]=="PP" | Lavin[,"Site"]=="CC" |
> Lavin[,"Site"]=="FH",]
>
> I then perform a glm using the data frame and plot the results.
>
> fit1poisson<-glm(NumUniqOpPt~Seq+Site,family=poisson(link =
> "log"),data=ShortLavin,offset=log(NumUniqPt))
> plot(fit1poisson)
>
> On the plots I see a point labeled as 127 that is an extreme value.
> I want to re-run the glm excluding the extreme observation. I have
> tried several methods to exclude the observation (shown below), none
> have worked.
>
> Minus127<-ShortLavin[-127,]
> Minus127<-ShortLavin[-"127",]
> Minus127<-ShortLavin[-c(127),]
> Minus127<-ShortLavin[-c("127"),]
>
> None of these worked. Suggestions on how I can remove observation
> 127 would be appreciated
>
> Thank you,
> John
>
> John Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)

>
> Confidentiality Statement:
> This email message, including any attachments, is for\...{{dropped:14}}



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. Received on Tue 04 Mar 2008 - 14:11:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 04 Mar 2008 - 14:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive