[R] remove last row of a data frame
Daniel Nordlund
djnordlund at frontier.com
Wed Dec 12 08:58:14 CET 2012
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of e-letter
> Sent: Tuesday, December 11, 2012 11:45 PM
> To: r-help at r-project.org
> Subject: [R] remove last row of a data frame
>
> Readers,
>
> For a data set 'a':
>
> 1
> 2
> 3
> 4
>
> Please what is the syntax to remove the last row and create a new object
> 'b':
>
> 1
> 2
> 3
>
> Thanks.
>
If by data set a you mean a data frame called a, then something like this should work:
b <- a[-nrow(a),]
If you haven't already read the manual, "An Introduction to R", that ships with every copy of R, then now is the time.
hope this is helpful,
Dan
Daniel Nordlund
Bothell, WA USA
More information about the R-help
mailing list