[R] How to read this file into R.

Phil Spector spector at stat.berkeley.edu
Fri Sep 24 23:45:44 CEST 2010


Changbin -
    If you want the entire line, use

> readLines('~/ca_boost_feature.txt',warn=FALSE)[2]
[1] " H.2.C C.1.D C.3.R E.0.N C.2.S C.0.G H.3.G"

    If you want a vector with the contents of the line, use

> scan('~/ca_boost_feature.txt',skip=1,n=7,what='')
Read 7 items
[1] "H.2.C" "C.1.D" "C.3.R" "E.0.N" "C.2.S" "C.0.G" "H.3.G"

Hope this helps.
 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu





On Fri, 24 Sep 2010, Changbin Du wrote:

> Dear community,
>
> I have one file named ca_boost_feature.txt,
>
> Feature selection (Boosting:0.0025,5)!
> H.2.C C.1.D C.3.R E.0.N C.2.S C.0.G H.3.G
> log file: ep
>
> If I want to use the second line of this file, how to read it into R?
>
> varr<-read.table("/home/cdu/operon/carbonic/ca_boost_feature.txt", sep=" ",
> skip=1, header=F, strip.white=TRUE, nrows=1)
> Warning message:
> In read.table("/home/cdu/operon/carbonic/ca_boost_feature.txt",  :
>  incomplete final line found by readTableHeader on
> '/home/cdu/operon/carbonic/ca_boost_feature.txt'
>
> I attached this file with this email.
>
> Thanks!
>
>
> -- 
> Sincerely,
> Changbin
> --
>



More information about the R-help mailing list