R Markdown - SQL R - Mixing Variables

Hello guys,

I would like to know your opinion,
I am trying to blend r and SQL. What I would like is to extract from a SQL Table (in an Oracle Server) filtering just the countries that I am interested to analyze provided by an R array.

Is this possible?
What is the best way to mix r variables with SQL queries

Here the example:

``{r}

Country_List <- c("Spain","Italy","France","Belgium")

``

``{sql, connection=con, output.var="Data"}

SELECT ID, Company,Country
FROM Data
WHERE Country IN Country_List

``

Thank you very much

Here is a nice walk around solution that uses glue::glue_sql() to prepare the array to be passed to the SQL chunk as an R variable

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.