[1] -0.5604756 -0.2301775 1.5587083
[1] -0.6264538 0.1836433 -0.8356286
[1] -0.5604756 -0.2301775 1.5587083
Block 2, Session 2: Programming with Data
see also: RSE Book on Data Management
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
examples:
library(RSQLite)
db_path = "../data/h4sci.sqlite3"
con <- dbConnect(RSQLite::SQLite(), db_path)
dbWriteTable(con, dbQuoteIdentifier(con,"mtcars"), mtcars, overwrite = T)
dbWriteTable(con, dbQuoteIdentifier(con,"flowers"), iris, overwrite = T)
dbGetQuery(con, "SELECT * FROM flowers LIMIT 3")
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
Note: Foreign Key Handling is very limited in SQLite.
SELECT * FROM schema.table;
INSERT INTO schema.table VALUES ('abc',2,3);
SELECT name, salary FROM staff
WHERE position = 'manager'
ORDER BY salary DESC;
RTFM
Experiment ‘per pedes’
Write a Wrapper if it does not exist
Use the Wrapper
Here is an R example to get ☔️ images from the MET collection.
Hacking for Science by Dr. Matthias Bannert is licensed under CC BY-NC-SA 4.0