On Sat, 19 Aug 2006, [EMAIL PROTECTED] wrote:

> Dear all,
> 
> I have a question about how to get a matrix by combining a large number of
> columns from a data file. Suppose I read a file which have 1000 columns
> by:
> 
> test = read.table("dat.txt", header=F)
> 
> I know I could use "cbind()". It's easy to do when the number of columns
> is small (i.e. cbind(test$V1, test$V2)). But how about build a matrix "X"
> by combine the first 500 columns. Is there an easy way to write the
> expression?

as.matrix(test[1:500])

Or read the data as a matrix in the first place, using scan (as 
recommended on the help page for read.table *and* the relevant manual).

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[email protected] 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