----- Original Message ----- From: "Covelli Paolo" <pcove...@tele2.it>
To: <r-help@r-project.org>
Sent: Thursday, April 08, 2010 9:05 AM
Subject: [R] use read.table for a partial reading


Hi everyone,

I've got a matrix data with 20 variables (V1, V2, V3, ...) and 215 rows (observations). I'm interested to read only the first and second variables using "read.table" function. How can I do?


You do not provide a reproducible example (see http://www.R-project.org/posting-guide.html), so my comments are somewhat of a guess.

Typically, when you read in data from a file in R, you read it into a 'data frame' not a matrix. (To earn more http://cran.r-project.org/doc/manuals/R-intro.html#Lists-and-data-frames)

This is how you would get your data (the dataframe) in the form you desire:
dat <- read.table("mydata.txt", header = TRUE)
dat2 <- dat[,1:2]  # contains just the first two variables, V1 and V2




Thanks in advance.

Paolo.

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


______________________________________________
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