How I can read dataframe in R Markdown using SQL?

I can read data from database using this code:

{sql connection=con} SELECT year, sex, age from INFROMATION

but how I can take that to data.frame?

Upvotes: 1

Views: 627

Answers (2)

conrad-mac
conrad-mac

Reputation: 893

From here:

If you want to assign the results of the SQL query to an R data frame, you can do this using the output.var option.

For example:

{sql, connection=con, output.var="info_query"}
SELECT year, sex, age from INFROMATION

Upvotes: 2

Daksh Agarwal
Daksh Agarwal

Reputation: 167

Did you try to put that directly in data = data.frame({sql connection=con} SELECT year, sex, age from INFROMATION) ?

Upvotes: 0

Related Questions