SQLite (with the RSQLite package) is perfect for quickly setting up a single-app database. Most examples of RSQLite use databases created in RAM, but that defeats the point here. You can create a single file that acts like a database:
library("RSQLite")
# Create a database file named db.sqlite
con <- dbConnect(RSQLite::SQLite(), "db.sqlite")
dbWriteTable(con, "mydata", mydata)
subtable <- dbGetQuery(
con, "SELECT * FROM mydata WHERE name = 'John Doe'"
)
dbWriteTable can also read data from a delimited data file into a database, with no leftover objects in the R session. This is helpful with huge data. It takes most of the arguments from read.table:
dbWriteTable(
conn = con,
name = "mydata",
value = "mydata.csv",
sep = ",",
header = TRUE,
overwrite = TRUE
)
Pair this with creating objects outside the server function, and you'll have a single database shared by all sessions.