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

alison waller alison.waller at embl.de
Mon Mar 8 14:06:02 CET 2010


Hello,

I am using RmySQL and would like to iterate through a few queries.

I would like to use sprintf but I think I'm having problems mixing and
matching the sprintf syntax and the SQL regex.

I have checked my sqlcmd and it works when I wan to match %MG1% but how
do I iterate for i 1-72?  Escape characters,?

thanks in advance

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%s%' ,i)

========= Here is my vague error message

Error: unexpected input in:



More information about the R-help mailing list