The data contain Motor Trends car testing results. There are 32 cars.
In [43]:
nrow(mtcars)
ncol(mtcars)
In [44]:
head(mtcars)
In [45]:
summary(mtcars)
In [46]:
library(sqldf)
# help(sqldf)
In [47]:
sqldf('select * from mtcars where cyl=6')
In [48]:
nrow(sqldf('select * from mtcars where cyl=6'))
In [49]:
sqldf('select count(*) from mtcars where cyl=6')
In [50]:
df = mtcars
df$name = rownames(df) # move R's rownames into their own column
write.table(df, "mtcars.csv", quote=TRUE, row.names=FALSE, col.names=FALSE, sep=",")
make mtcars-init
That will run the following:
sqlite3 mtcars.sqlite < mtcars-init.sql
That SQL file does the following:
In [51]:
library(RSQLite)
# connect to the database
db = dbConnect(SQLite(), dbname="mtcars.sqlite")
In [52]:
dbListTables(db)
In [53]:
dbListFields(db, "results")
In [54]:
dbGetQuery(conn = db, "select * from results where cyl=8")
In [ ]: