[R] include sql statements
MacQueen, Don
macqueen1 at llnl.gov
Mon Mar 3 20:49:55 CET 2014
One way would be
sql <- scan('stmt.sql', what='')
Then
sql <- paste(sql, collapse=' ')
or
sql <- paste(sql, collapse='\n')
After which you can check with
cat(sql, '\n')
I do this sort of thing when I want to maintain an SQL template in an
external file, then modify it in R before using one of the DBIs to submit
it to some external relational database.
-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 2/28/14 2:16 AM, "Streng Ge-heim" <normannus1 at gmail.com> wrote:
>Hi,
>
>first of all: I am new to R. Anyway, I would like to include sql files in
>my r-script, which I load via source("scriptname") in the CLI.
>
>The sql files (i.e. "stmt.sql") contains select statements with joins,
>line
>breaks, various characters, they can be quite long.
>
>My question is, is there a way to include external sql files for further
>processing? Or how can I include them. I tried it with source(),
>read.table
>but I could get it to work.
>
>Thanks, regards
>Michel
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at 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.
More information about the R-help
mailing list