[R] question about read.columns
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) dim(hh) 468, 2402 hh-read.columns(/house/homedirs/c/cdu/operon/gh/dd.dimer, required.col=var, text.to.search=, sep=\t, skip=0, quote=, fill=T) dim(hh) 0, 0 Can anyone help me with this? Thanks, -- Sincerely, Changbin -- [[alternative HTML version deleted]] __ 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.
Re: [R] question about read.columns
On Wed, Jun 22, 2011 at 5:45 PM, Changbin Du changb...@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 __ 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.
Re: [R] question about read.columns
Hi, Gabor, Thanks so much, I will try it and let you know the results. Appreciated! On Wed, Jun 22, 2011 at 2:54 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 22, 2011 at 5:45 PM, Changbin Du changb...@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 -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[alternative HTML version deleted]] __ 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.
Re: [R] question about read.columns
I found the following errors: library(sqldf) Loading required package: DBI Loading required package: RSQLite Loading required package: RSQLite.extfuns *Error: package 'RSQLite' 0.8-0 is loaded, but = 0.9.1 is required by 'RSQLite.extfuns'* hh-read.csv.sql(/house/homedirs/c/cdu/operon/gh5/hypo_re.dimer, header=FALSE, sep=\t,sql=select varr from file, quote=, fill=T) *Error: could not find function read.csv.sql* On Wed, Jun 22, 2011 at 2:57 PM, Changbin Du changb...@gmail.com wrote: Hi, Gabor, Thanks so much, I will try it and let you know the results. Appreciated! On Wed, Jun 22, 2011 at 2:54 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 22, 2011 at 5:45 PM, Changbin Du changb...@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 -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[alternative HTML version deleted]] __ 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.
Re: [R] question about read.columns
On Wed, Jun 22, 2011 at 6:01 PM, Changbin Du changb...@gmail.com wrote: I found the following errors: library(sqldf) Loading required package: DBI Loading required package: RSQLite Loading required package: RSQLite.extfuns Error: package 'RSQLite' 0.8-0 is loaded, but = 0.9.1 is required by 'RSQLite.extfuns' hh-read.csv.sql(/house/homedirs/c/cdu/operon/gh5/hypo_re.dimer, header=FALSE, sep=\t,sql=select varr from file, quote=, fill=T) Error: could not find function read.csv.sql Make sure you are using the most recent versions of R, RSQLite and sqldf. packageVersion(sqldf) [1] ‘0.4.1’ packageVersion(RSQLite) [1] ‘0.9.4’ R.version.string [1] R version 2.13.0 Patched (2011-06-09 r56106) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ 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.
Re: [R] question about read.columns
My R is 2.12.0. R.version.string [1] R version 2.12.0 (2010-10-15) packageVersion(RSQLite) [1] '0.8.0' packageVersion(sqldf) [1] '0.3.5' So it seems I have to update or install the 2.13.0 version in my linux machine. On Wed, Jun 22, 2011 at 3:04 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 22, 2011 at 6:01 PM, Changbin Du changb...@gmail.com wrote: I found the following errors: library(sqldf) Loading required package: DBI Loading required package: RSQLite Loading required package: RSQLite.extfuns Error: package 'RSQLite' 0.8-0 is loaded, but = 0.9.1 is required by 'RSQLite.extfuns' hh-read.csv.sql(/house/homedirs/c/cdu/operon/gh5/hypo_re.dimer, header=FALSE, sep=\t,sql=select varr from file, quote=, fill=T) Error: could not find function read.csv.sql Make sure you are using the most recent versions of R, RSQLite and sql packageVersion(sqldf) [1] 0.4.1 packageVersion(RSQLite) [1] 0.9.4 R.version.string [1] R version 2.13.0 Patched (2011-06-09 r56106) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[alternative HTML version deleted]] __ 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.
Re: [R] question about read.columns
On Wed, Jun 22, 2011 at 6:10 PM, Changbin Du changb...@gmail.com wrote: My R is 2.12.0. R.version.string [1] R version 2.12.0 (2010-10-15) packageVersion(RSQLite) [1] '0.8.0' packageVersion(sqldf) [1] '0.3.5' So it seems I have to update or install the 2.13.0 version in my linux machine. R 2.12 might work but you should certainly update your packages. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ 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.
Re: [R] question about read.columns
I will try this first. Thanks, Gabor! On Wed, Jun 22, 2011 at 3:15 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 22, 2011 at 6:10 PM, Changbin Du changb...@gmail.com wrote: My R is 2.12.0. R.version.string [1] R version 2.12.0 (2010-10-15) packageVersion(RSQLite) [1] '0.8.0' packageVersion(sqldf) [1] '0.3.5' So it seems I have to update or install the 2.13.0 version in my linux machine. R 2.12 might work but you should certainly update your packages. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[alternative HTML version deleted]] __ 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.
Re: [R] question about read.columns
INstalling of RSQLite was successful. in R: packageVersion(RSQLite) [1] '0.9.4' When I try to install sqldf, I found the following errors: install.packages(sqldf) Installing package(s) into '/house/homedirs/c/cdu/library/' (as 'lib' is unspecified) trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/sqldf_0.4-0.tar.gz' Content type 'application/x-gzip' length 19920 bytes (19 Kb) opened URL == downloaded 19 Kb *ERROR: failed to lock directory '/house/homedirs/c/cdu/library' for modifying Try removing '/house/homedirs/c/cdu/library/00LOCK' * The downloaded packages are in '/tmp/RtmpszmT38/downloaded_packages' Warning message: In install.packages(sqldf) : installation of package 'sqldf' had non-zero exit status When I try to remove the */house/homedirs/c/cdu/library/00LOCK'* by rm -r 00LOCK, I got the following errors: cdu@nuuk:~/library$ rm -r 00LOCK *rm: cannot remove `00LOCK/RSQLite/libs/.nfs0001301e52e4': Device or resource busy* Not known what happened. Gabor, do you have any idea? Thanks! On Wed, Jun 22, 2011 at 3:24 PM, Changbin Du changb...@gmail.com wrote: I will try this first. Thanks, Gabor! On Wed, Jun 22, 2011 at 3:15 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Jun 22, 2011 at 6:10 PM, Changbin Du changb...@gmail.com wrote: My R is 2.12.0. R.version.string [1] R version 2.12.0 (2010-10-15) packageVersion(RSQLite) [1] '0.8.0' packageVersion(sqldf) [1] '0.3.5' So it seems I have to update or install the 2.13.0 version in my linux machine. R 2.12 might work but you should certainly update your packages. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[alternative HTML version deleted]] __ 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.
Re: [R] question about read.columns
On Wed, Jun 22, 2011 at 7:07 PM, Changbin Du changb...@gmail.com wrote: INstalling of RSQLite was successful. in R: packageVersion(RSQLite) [1] '0.9.4' When I try to install sqldf, I found the following errors: install.packages(sqldf) Installing package(s) into '/house/homedirs/c/cdu/library/' (as 'lib' is unspecified) trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/sqldf_0.4-0.tar.gz' Content type 'application/x-gzip' length 19920 bytes (19 Kb) opened URL == downloaded 19 Kb ERROR: failed to lock directory '/house/homedirs/c/cdu/library' for modifying Try removing '/house/homedirs/c/cdu/library/00LOCK' The downloaded packages are in '/tmp/RtmpszmT38/downloaded_packages' Warning message: In install.packages(sqldf) : installation of package 'sqldf' had non-zero exit status When I try to remove the /house/homedirs/c/cdu/library/00LOCK' by rm -r 00LOCK, I got the following errors: cdu@nuuk:~/library$ rm -r 00LOCK rm: cannot remove `00LOCK/RSQLite/libs/.nfs0001301e52e4': Device or resource busy Not known what happened. Gabor, do you have any idea? Thanks! You will need to remove the lock file. Try shutting down any processes that could be trying to access it *e.g. all R processes and all shells) and then try removing it again. If need be change the file's permissions and/or try as root. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ 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.