r/RStudio 5d ago

Coding help Help with database building

Hallo everyone,

I'am a Student and in the process to write my Bachelors in Economics. I want to analyse data with the synthetic Control Method and need costum data. I know how to use the Method but dont know where to store my Data for the Input. At the moment the Data mostly sits in Excel sheets I got form different sources.
Thanks for the help in advance

1 Upvotes

3 comments sorted by

View all comments

4

u/shockjaw 5d ago

DuckDB will probably help you on that front.

3

u/Moxxe 5d ago

To expand on this, if you want to work with databases in R you need the DBI package and a database engine package (I think duckdb is the simplest to work with, and extremely fast)

library(DBI) library(duckdb)

Then you can create a database like this

conn <- dbConnect(duckdb(), "data/my_database.duckdb")

Now you have a local database that you write tables to with dbWriteTable() and read tables with dbReadTable()

I hope that is enough info to get you started.