[R] read.delim: only first column import

Liaw, Andy andy_liaw at merck.com
Fri Apr 15 16:25:31 CEST 2005


You can use colClasses; e.g.,

> write.table(iris, file="iris.dat", sep="|", quote=FALSE, row=FALSE)
> test <- read.delim("iris.dat", sep="|", header=TRUE, 
>                    colClass=c("numeric", rep("NULL", 4)))
> head(test)
  Sepal.Length
1          5.1
2          4.9
3          4.7
4          4.6
5          5.0
6          5.4


Andy

> From: Christoph Lehmann
> 
> Hi
> if I use read.delim, I can specify how many lines I want to import.
> Is there also a way to specify that, e.g. I want only the 
> first column 
> field of each line to have imported?
> 
> thanks for a hint
> cheers
> christoph
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 
>




More information about the R-help mailing list