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? Thanks in advance. Paolo.
use read.table for a partial reading
4 messages · Covelli Paolo, PIKAL Petr, Robert Baer +1 more
Hi what about some.data <- read.table(....)[ ,1:2] Regards Petr r-help-bounces at r-project.org napsal dne 08.04.2010 16:05:39:
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? Thanks in advance. Paolo.
______________________________________________ R-help at 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.
2 days later
----- Original Message ----- From: "Covelli Paolo" <pcovelli at tele2.it> To: <r-help at 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 at 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.
Try this also:
your_data <- read.table('your_file.txt', colClasses = c('character',
'character', rep(NULL, 18)))
On Thu, Apr 8, 2010 at 11:05 AM, Covelli Paolo <pcovelli at tele2.it> wrote:
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? Thanks in advance. Paolo.
______________________________________________ R-help at 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.
Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O