[R] include sql statements
Jeff Newmiller
jdnewmil at dcn.davis.CA.us
Sun Mar 2 17:42:33 CET 2014
R does not require the begin and end quote marks for string literals to be on the same line. There is nothing preventing you from formatting your SQL to your preference right in within R code.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
On March 2, 2014 5:06:32 AM PST, normannus <normannus1 at gmail.com> wrote:
>Am 28.02.2014 20:54, schrieb Duncan Murdoch:
>> On 28/02/2014 5:16 AM, Streng Ge-heim 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.
>>
>> SQL is a different language from R. You shouldn't expect source() to
>
>> work.
>>
>> You can process SQL using RODBC or various other database packages,
>> e.g. RSQLite. They send the SQL statements to a database for
>processing.
>>
>> Duncan Murdoch
>Thank you,
>but I already use the ODBC R-library for connecting to the MySQL
>Server.
>The problem I have is to put the sql statement into my script.R, or
>better to say to load it into my script. SInce some sql-statements ar
>quite long, using many line-breaks to keep the statement readable,
>using
>control structures like if and case I could not manage to work it yet.
>Because I do not like to format (to put it in one line, only) my sql
>statement eacht time I process it with R.
>
>Regards, Michel
>
>______________________________________________
>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