How about:

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


Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(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




______________________________________________
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.

Reply via email to