[R] how to keep row name if there is only one row selected from a data frame

agent dunham crosspide at hotmail.com
Wed Nov 23 11:37:36 CET 2011


Dear Community, 

I'm having a similar problem. I'm working with the data.frame attached (
http://r.789695.n4.nabble.com/file/n4099139/df1.xls df1.xls ), let's call it
df1 (and when I type str(df1) it answers data.frame)  

df1 has its own rownames (In the .xls the column "id", not 1,2,3, ...), and
its dimension is 80x7 

I'd like to drop rows by their rownames; in fact I'd like to drop rows
"2098", "2200" and "784" How can I do it?

I've tried: 

a) df2outliers <- df1 %in% (2098,2970,784) 

b) df1<- df1[-2098, , drop= TRUE]

But it seems rows are undefined. However when I uploaded this .xls I typed: 

df1<- read.xls("C:/... dir .../df1.xls",colNames= TRUE, *rowNames= TRUE*)  

Why do I loose rownames although I said rowNames= TRUE ? user at host.com




--
View this message in context: http://r.789695.n4.nabble.com/how-to-keep-row-name-if-there-is-only-one-row-selected-from-a-data-frame-tp895594p4099139.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list