Skip to content

Removing rows in a data frame

4 messages · Charles Thuo, Bert Gunter, Rainer Schuermann +1 more

#
I have a data frame whose rows are 678013 . I would like to  remove rows
from 30696 to 678013 and then attach a new column with a length of 30595.


I tried

Y<- X[-30595:678013,] and its not working

In addition how do i add a new column

Kindly assist.

Charles
#
?precedence

-5:10 is (-5):10

-- Bert


Bert Gunter

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
   -- Clifford Stoll
On Thu, Jul 2, 2015 at 10:23 PM, Charles Thuo <tcmuigai at gmail.com> wrote:
#
Try

y <- x[ -( 30596:678013 ), ]

Please note that I have replaced 30595 with 30596 which is I think what you mean.

You can add a new column with

y$new <- new_column   # this is your vector of length 30595

Good luck,
Rainer
On Friday 03 July 2015 07:23:28 Charles Thuo wrote:
#
In my experience package "dplyr" has all functions to deal with this kind
of problems in a simple and compact way
Sergio
Il 03/lug/2015 07:26, "Charles Thuo" <tcmuigai at gmail.com> ha scritto: