image Post Your Answer


image

Run SQL queries in R

5 years ago in Discussion By Radhey Shyam

SQL

I want to run SQL queries in R with sqldf package. How do I do it?

All Answers (2 Answers In All)

By Kamlesh Meena Answered 5 years ago

Hey. Just follow the below steps. You can easily run SQL queries by To install and load packages install.packages(“sqldf”) library(sqldf) 2. To create a sample data dt <- data.frame( ID = c('X1','X2','X4','X2','X1','X4','X3','X2','X1','X3'), Value = c(4,3,1,3,4,6,6,1,8,4))


By Manpreet Jaiswal Answered 5 years ago

The sqldf package can be used to run sql queries on R data frames. Simply specify a sql statement enclosed by quotation marks within the sqldf() function. If you want to find the total number of rows which meets a certain condition, you can make use of sql command COUNT(). Furthermore, GROUP BY() lets you to structure the data in compliance with the levels of a particular variable.


Your Answer


View Related Questions