Creating and interacting with the SQLite database from R
The SQLite
library implements serverless, self-contained, and zero-configuration database engines. Also, SQLite
is publicly available free of cost. You can create, store, and interact with the SQLite
database from R. In this recipe, you will create a new database in SQLite
and insert a data table with the mtcars
data from R.
Getting ready
To implement this recipe, you will need the following libraries installed onto your computer:
RSQLite
DBI
sqldf
You can use the following code to install the RSQLite
library with its necessary dependencies:
install.packages("RSQLite", dependencies = TRUE)
In this recipe, you will use the mtcars
dataset from the datasets
library. This is one of the well-known default datasets in R containing various characteristics of a car. Once the library installation is completed, you are ready to go.
The task is to create a new database called dbNew
and then create a table cardata
containing the mtcars
dataset. Finally...