[R] Multi-line paste function

Philippe Grosjean phgrosjean at sciviews.org
Tue Mar 14 20:39:07 CET 2006


Lapointe, Pierre wrote:
> Hello Phillipe
> 
> 1-You are right that for a simple example as the one I provided, paste and
> gsub give the same result.
> 2-For a more complex case, where let's say, I'd like to include a variable
> in my SQL statement, the multi.line.paste command is essential.
> 
> variable <-1.9
> multi.line.paste("
> SELECT * 
> FROM estimates3 a, newtable b 
> WHERE a.Ticker=b.Ticker 
> AND a.Fiscal_Year=b.Fiscal_Year
> AND a.EPS<>b.EPS 
> AND a.Date_Last_change_or_conf-",variable,">b.Date_Last_change_or_conf
> ",sep="")
> 
> Regards,
> 
> Pierre 

Still simpler than your function:

variable <- 1.9
gsub("\"", "", paste("
SELECT *
FROM estimates3 a, newtable b
WHERE a.Ticker=b.Ticker
AND a.Fiscal_Year=b.Fiscal_Year
AND a.EPS<>b.EPS
AND a.Date_Last_change_or_conf-",variable,">b.Date_Last_change_or_conf
", sep=""))

Philippe Grosjean




More information about the R-help mailing list