On Tue, 2006-08-22 at 07:32 -0700, Srinivas Iyyer wrote:
> Dear marc: thank you for your tip. 
> 
> > > cat(x.new, "\n")
> > 3\',5\'-cyclic-nucleotide phosphodiesterase activity
> > 
> 
> here cat is printing on screen. 
> 
> how can I direct the output to an object. 
> 
> I cannot do:
> 
> y <- cat(x.new, "\n")
> 
> is there any other way.
> 
> thanks
> srini

Srini,

Going back to your initial post, try something like the following using
paste():

> x <- "3',5'-cyclic-nucleotide phosphodiesterase activity"

> x.new <- gsub("'", "\\\\'", x)

#Note the escaping of the single quotes here:
> sql.cmd <- paste("fetch_count_fterm_sql(\'", (x.new), "\');", 
                   sep = "")

# Beware any line wrapping here
> sql.cmd
[1] "fetch_count_fterm_sql('3\\',5\\'-cyclic-nucleotide phosphodiesterase 
activity');"


This way the character vector 'sql.cmd' has the full sql query, which
you can then pass to your statement processing code.

I'm not sure how you are passing the code, but if in a text file as
input, you can do something like:

> sink("sqlfile.txt")
> cat(sql.cmd, "\n")
> sink()


Where the text file 'sqlfile.txt' will contain the single line:

fetch_count_fterm_sql('3\',5\'-cyclic-nucleotide phosphodiesterase activity'); 

See ?sink for more information.

HTH,

Marc

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to