[R] queries return different output when sourced

Thierry Onkelinx thierry.onkelinx at inbo.be
Fri Dec 4 14:45:58 CET 2015

Dear all,

We need to run several queries in an R Markdown file. The queries have quit
elaborate sql statements. We try to recude the amount of code in the
markdown file by moving the query functions in a seperate R script which is
sourced by the markdown file.

The queries work fine if we place the code directly in the markdown file
but fail when sourced. They return an empty data.frame with the correct
colnames. We have attached a minimal example.

Can someone tell us why the sourced functions give the a different output?

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
------------- volgend deel ------------
Een niet-tekst bijlage is gescrubt...
Naam: QueriesTest.pdf
Type: application/pdf
Grootte: 103077 bytes
Omschrijving: niet beschikbaar
URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20151204/f1bd4bcc/attachment.pdf>

More information about the R-help mailing list