nz-social-investment-agency / social_housing

Repository for the code required to run the Social Housing Technical Report analysis end-to-end.
GNU General Public License v3.0
0 stars 2 forks source link

file() versus just a straight string when importing SQL code into R #2

Closed ellisp closed 7 years ago

ellisp commented 7 years ago

In https://github.com/nz-social-investment-agency/social_housing/blob/master/rprogs/1.%20extract_dataset.R, for me

app_data-query <- file("../sql/source_data_query.sql", "r")

leads to the subsequent call to read_sql_table not working (it sends an empty character string to the database). Whereas the simpler

app_data-query <- "../sql/source_data_query.sql"

Works fine. So why not just use the simpler string?

vinaybenny commented 7 years ago

Cause: Unknown, as I'm unable to replicate the error. Wondering if differences in library version are causing the problem.

Fix: Since Peter's suggestion of using the string works anyway, I'm replacing the line as per Peter's suggestion. Can be closed once the code is signed out.