Re: [R] using sprintf to pass a variable to a RMySQL query

2010-03-11 Thread alison waller
Hi all, I re-installed R and tcltk. I find some of the documentation misleading as it indicates that tcltk is included with R. And when you type library() it shows tcltk, even though it hasn't been installed. Anyways, I've decided to go with sprintf. I am having errors with my query criteria.

Re: [R] using sprintf to pass a variable to a RMySQL query

2010-03-11 Thread Uwe Ligges
On 10.03.2010 12:45, alison waller wrote: Thanks Gabor, As I said I would like to use gsubfn, but I am having problems installing it, which I assume are due to some conflict with the current tcltk package Below is the error I got after issuing install.packages("gsubfn") Any advice? Re-insta

Re: [R] using sprintf to pass a variable to a RMySQL query

2010-03-10 Thread alison waller
Thanks Gabor, As I said I would like to use gsubfn, but I am having problems installing it, which I assume are due to some conflict with the current tcltk package Below is the error I got after issuing install.packages("gsubfn") Any advice? ### * Installing *source* package 'gsu

Re: [R] using sprintf to pass a variable to a RMySQL query

2010-03-10 Thread Gabor Grothendieck
There is likely something wrong with your R installation. tcltk is a recommended package and normally comes bundled with R. You should not have to install it separately. Try reinstalling R. Alternately, try the older version of gsubfn at: http://cran.r-project.org/src/contrib/Archive/gsubfn

Re: [R] using sprintf to pass a variable to a RMySQL query

2010-03-09 Thread alison waller
Hi all, Thanks for help with the paste and sprintf syntax. So I've decided to use paste and or sprintf. 'gsubfn' looks like a great package but unfortunately I've had problems installing it, as I don't think it likes the version of tcltk that is installed. I'm working on a few unix clusters wit

Re: [R] using sprintf to pass a variable to a RMySQL query

2010-03-09 Thread Gabor Grothendieck
On Tue, Mar 9, 2010 at 7:10 AM, alison waller wrote: > Hi all, > > Thanks for help with the paste and sprintf syntax. > > So I've decided to use paste and or sprintf.  'gsubfn' looks like a > great package but unfortunately I've had problems installing it, as I > don't think it likes the version o

Re: [R] using sprintf to pass a variable to a RMySQL query

2010-03-08 Thread Don MacQueen
I always use paste() i <- 1 sqlcmd_ScaffLen <- paste("SELECT scaffold.length FROM scaffold, scaffold2contig, contig2read WHERE scaffold.scaffold_id=scaffold2contig.scaffold_id AND scaffold2contig.contig_id=contig2read.contig_id AND contig2read.read_id LIKE '%MG", i ,"%'", sep='') That should cre

Re: [R] using sprintf to pass a variable to a RMySQL query

2010-03-08 Thread Gabor Grothendieck
Another possibility is to use fn$ in the gsubfn package. Just preface any command with fn$ to enable a quasi-perl-like string interpolation. In this example $i is replaced with 1: > library(gsubfn) > library(sqldf) > i <- 1 > fn$sqldf("select count(*) from CO2 where Plant like '%n$i%'") count(*)

Re: [R] using sprintf to pass a variable to a RMySQL query

2010-03-08 Thread jim holtman
Try this: i<-1 sqlcmd_ScaffLen<-sprintf('SELECT scaffold.length FROM scaffold,scaffold2contig,contig2read WHERE scaffold.scaffold_id=scaffold2contig.scaffold_id AND scaffold2contig.contig_id=contig2read.contig_id AND contig2read.read_id LIKE \'%%MG%d%%\'' ,i) sqlcmd_ScaffLen Your problem: 1. Need