Skip to content
Back to formatted view

Raw Message

Message-ID: <Xns9A5DEA488E945dNOTwinscomcast@80.91.229.13>
Date: 2008-03-11T03:01:43Z
From: David Winsemius
Subject: combining/deleting rows

"Suran, Luciana @ Torto Wheaton Research"
<Luciana.Suran at tortowheatonresearch.com> wrote in
news:09EBE0E1A7DEA24CAD5EA6827A7EB16D0C620EF5 at usidcxmb02.us.cbre.net: 

> I'm new to R and have some question on combining (and deleting)
> rows. 

You posted your email in response to a question that had nothing to do 
with this question. If you have new question, you should not send a 
reply to someone else's question.
 
> I have a dataset that looks like this: 
> 
      <snipped single element per line listing with 47 elements>


The lines you posted had no organization that would suggest they had 
ever been part of a data.frame. The first 5 elements looked to be 
variable names. But the number of elements was not evenly divisible by 
5.  Can you post a new message with complete data and the code (or 
method) that you used to bring this data into the R environment?

> 
> How can I add row 1 to row 24? 

If this is arranged as only one column, and you wanted the value in row 
24, then the code might be:

df[24] <- df[24] + df[1]

> Also, how can I delete rows from the  dataframe?

You could assign another object the values in the first object rows 
that you wanted kept:

df2 <- df[c(1:3, 5:10), ]

Or you could exclude the rows you wanted dropped using a minus-sign:

df2 <- df[-4,]

df2 <- df[-c(2,5,8), ]

-- 
David Winsemius