[R] question about read.columns
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Jun 22 23:54:18 CEST 2011
On Wed, Jun 22, 2011 at 5:45 PM, Changbin Du <changbind at gmail.com> wrote:
> HI, Dear R community,
>
> I have a large data set names dd.txt, the columns are: there are 2402
> variables.
>
> a1, b1, ..z1, a11, b11, ...z11, a111, b111, ..z111..
>
> IF I dont know the relative position of the columns, but I know I need the
> following variables:
> var<-c(a1, c1,a11,b11,f111)
>
> Can I use read.columns to read the data into R?
>
> I have tried the following codes, but it does not work
>
> hh<-read.columns("/house/homedirs/c/cdu/operon/gh/dd.dimer",
> required.col=NULL, text.to.search=var, sep="\t", skip=0, quote="", fill=T)
>
Depending on the precise format of the input you might be able to use
read.csv.sql in sqldf. (You may need to modify the args a bit
relative to what is shown below but the basic idea is hopefully
clear.) See ?read.csv.sql and also the examples on the sqldf home
page (http://sqldf.googlecode.com) for more info.
library(sqldf)
DF <- read.csv.sql("myfile", header = FALSE, sep = "\t", sql = "select
a1,c1,a11,b11,f111 from file")
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list