Another option (better or worse probably depends on many things) is to use:

b <- head(a, -1)


On Wed, Dec 12, 2012 at 1:14 AM, e-letter <inpost@gmail.com> wrote:

> On 12/12/2012, Daniel Nordlund <djnordlund@frontier.com> wrote:
> >> -----Original Message-----
> >> From: r-help-bounces@r-project.org [mailto:r-help-bounces@r-project.org
> ]
> >> On Behalf Of e-letter
> >> Sent: Tuesday, December 11, 2012 11:45 PM
> >> To: r-help@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.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538280@gmail.com

	[[alternative HTML version deleted]]


