forked from datapages/irw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.qmd
76 lines (54 loc) · 2.35 KB
/
data.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
title: "Data"
---
{{< include _load-data.qmd >}}
Below we show metadata for the entire IRW, an example dataset, and illustrations of how to access the data programmatically. You can also explore the data [here](https://redivis.com/datasets/as2e-cv7jb41fd/tables).
## Metadata
<iframe width="800" height="500" allowfullscreen src="https://redivis.com/embed/tables/mikabr.irw:qa4k.metadata_output:vvkq#cells" style="border:0;"></iframe>
## Individual dataset
```{ojs}
summaries_map = new Map(Object.entries(summaries))
viewof dataset = Inputs.select(summaries_map, {label: 'Dataset'})
// Function to find the key that corresponds to the selected dataset
function findDatasetNameFromMap(map, selectedDataset) {
for (let [key, value] of map.entries()) {
if (value === selectedDataset) {
return key;
}
}
return null;
}
// Look up the name of the dataset and set up the URL
dataset_name = findDatasetNameFromMap(summaries_map, dataset);
dataset_url = "https://redivis.com/embed/tables/datapages.item_response_warehouse:as2e:current." + dataset_name
html`<iframe id="myIframe" width="800" height="500" allowfullscreen style="border:0;" src = "${dataset_url}"></iframe>`
```
## Programmatic access
You can also access IRW data programmatically using the Redivis API for [R](https://apidocs.redivis.com/client-libraries/redivis-r) or [Python](https://apidocs.redivis.com/client-libraries/redivis-python) (**note** that you will first need to [generate and set an API token](https://apidocs.redivis.com/client-libraries/redivis-r/getting-started)). For example:
::: {.panel-tabset}
## R
```{r}
#| eval: false
#| echo: true
# first install redivis package: devtools::install_github("redivis/redivis-r", ref="main")
# individual dataset
dataset <- redivis::user("datapages")$dataset("item_response_warehouse")
df <- dataset$table("4thgrade_math_sirt")$to_tibble()
# metadata
project <- redivis::user("mikabr")$project("irw")
metadata <- project$table("metadata_output")$to_tibble()
```
## Python
```{python}
#| eval: false
#| echo: true
#| python.reticulate: false
import redivis
# individual dataset
dataset = redivis.user('datapages').dataset('item_response_warehouse')
df = dataset.table('4thgrade_math_sirt').to_pandas_dataframe()
# metadata
project = redivis.user('mikabr').project('irw')
metadata = project.table('metadata_output').to_pandas_dataframe()
```
:::