remove last row of a data frame
On 12/12/2012, Daniel Nordlund <djnordlund at frontier.com> wrote:
-----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.
Thanks, couldn't find quickly the relevant section in the html document, but within R, the command 'nrow' is relevant.