Nason commited on
Commit
1e70c77
·
verified ·
1 Parent(s): 78f3d50

Add tested R query how-to and correct usage examples

Browse files
Files changed (1) hide show
  1. README.md +17 -0
README.md CHANGED
@@ -46,6 +46,23 @@ WHERE program_year = 2024
46
  GROUP BY 1 ORDER BY 2 DESC LIMIT 10;
47
  ```
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  Joins to the `cms-medicare` datapond database on NPI — see the GitHub README
50
  for the worked Open Payments x Medicare utilization example and measured
51
  join rates.
 
46
  GROUP BY 1 ORDER BY 2 DESC LIMIT 10;
47
  ```
48
 
49
+ ### R with DBI and duckdb
50
+
51
+ Install the dependencies once with `install.packages(c("DBI", "duckdb"))`.
52
+
53
+ ```r
54
+ library(DBI)
55
+ con <- dbConnect(duckdb::duckdb())
56
+ dbExecute(con, "INSTALL httpfs")
57
+ dbExecute(con, "LOAD httpfs")
58
+ dbExecute(con, "ATTACH 'https://huggingface.co/datasets/Nason/openpayments-database/resolve/main/openpayments.duckdb' AS op (READ_ONLY)")
59
+ dbGetQuery(con, "SELECT program_year FROM op.general_payments LIMIT 5")
60
+ dbDisconnect(con, shutdown = TRUE)
61
+ ```
62
+
63
+ DuckDB uses HTTP range requests; queries run on your machine and may need substantial memory or download data. A `LIMIT` does not guarantee a small scan.
64
+
65
+
66
  Joins to the `cms-medicare` datapond database on NPI — see the GitHub README
67
  for the worked Open Payments x Medicare utilization example and measured
68
  join rates.