[R] edit.row.names taking row names from the edited dataframe

Ross Culloch ross.culloch at dur.ac.uk
Thu Jul 30 20:46:07 CEST 2009


Hi all,

I am struggling to work out how to use the rownames from an edited dataframe
rather than the row names from the original dataframe. In my data set i'm
trying to extract several rows of data on particular individuals, i don't
doubt i'm using the long way round but what i have in the way of a script is
this:


##selecting the IDs from the dataframe individually
A1<-mumpup[ID=="A1",]
B1<-mumpup[ID=="B1",]
B2<-mumpup[ID=="B2",]
B3<-mumpup[ID=="B3",]
B4<-mumpup[ID=="B4",]
B6<-mumpup[ID=="B6",]
B7<-mumpup[ID=="B7",]
B8<-mumpup[ID=="B8",]
B9<-mumpup[ID=="B9",]
B13<-mumpup[ID=="B13",]
C1<-mumpup[ID=="C1",]
G1<-mumpup[ID=="G1",]

data<-rbind(A1,B1,B2,B3,B4,B6,B7,B8,B9,B13,C1,G1)

It works fine to a certain extent, the only problem being that i get are all
the IDs in the original dataframe so if i use

summary(data$ID)

I get:

 A1  B1 B10 B13  B2  B3  B4  B6  B7  B8  B9  C1  G1  G3  H2  H9  J1  J2  J3 
K1 
354 354   0 354 354 354 354 354 354 354 354 246 210   0   0   0   0   0   0  
0 

So it does take the data out of the dataframe but it keeps the IDs for some
reason.

I have looked at the edit.data.frame help and i understand why it is
happening, it is taking the rownames from the original dataframe and not the
edit and it seems i should use edit.row.names=T in my script, but i can't
get that to work.

Does anyone have any suggestions at all? Any help is much appreciated,

Best wishes,

Ross

-- 
View this message in context: http://www.nabble.com/edit.row.names-taking-row-names-from-the-edited-dataframe-tp24744741p24744741.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list