[R] The end of Matlab

Patrick Burns pburns at pburns.seanet.com
Fri Dec 12 13:10:20 CET 2008

How about:

x[, -seq(to=ncol(x), length=n)]

Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
(home of S Poetry and "A Guide for the Unwilling S User")

Claudia Beleites wrote:
> Dear list,
>> Learning to use the power of R's indexing and functios like head() and
>> tail() (which are just syntactic sugar) will probably lead you not to miss
>> this.
> However, how do I exclude the last columns of a data.frame or matrix (or, in 
> general, head and tail for given dimensions of an array)?
> I.e. something nicer than 
> t (head (t (x), -n))
> for excluding the last n columns of matrix x
> THX, Claudia

More information about the R-help mailing list