Skip to content
Back to formatted view

Raw Message

Message-ID: <5310E988.8090500@gmail.com>
Date: 2014-02-28T19:54:48Z
From: Duncan Murdoch
Subject: include sql statements
In-Reply-To: <CAF1gAhAfL=eRc9vr5mc9X2ixsbZv4NSK6S0vmk-84cZ-A22uZg@mail.gmail.com>

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