Examples

Querying data

Execute a query
1
# Perform a query on the Demo CMS Medicare data.
2
# Table at https://redivis.com/demo/datasets/1754/tables
3
data <- (
4
redivis::query("
5
SELECT * FROM demo.cms_2014_medicare_data.home_health_agencies
6
WHERE state = 'CA'
7
")
8
$to_tibble()
9
)
10
11
print(data) # data is a tibble
Copied!
Execute a scoped query
1
# Perform a query on the Demo CMS Medicare data.
2
# Table at https://redivis.com/demo/datasets/1754/tables
3
4
# We don't need to include fully-qualified table names
5
# if we scope our query to the appropriate dataset or project
6
7
data <- (
8
redivis::organization("Demo")
9
$dataset("CMS 2014 Medicare Data")
10
$query("
11
SELECT provider_name, average_total_payments
12
FROM nursing_facilities
13
INNER JOIN outpatient_charges USING (provider_id)
14
WHERE state = 'CA'
15
")
16
$to_tibble()
17
)
18
19
print(data)
Copied!

Reading table data

1
data <- (
2
redivis::organization("Demo")
3
$dataset("CMS 2014 Medicare Data")
4
$table("Hospice providers")
5
# We can specify an optional max_results argument to only
6
# load some of the records, and an optional variables
7
# argument to only load certain variables
8
$to_tibble(max_results=100, variables=c("name","city","state"))
9
)
10
11
print(data)
Copied!