2023-04-13 10:57:04 +02:00
|
|
|
---
|
|
|
|
title: "Introduction"
|
|
|
|
output: rmarkdown::html_vignette
|
|
|
|
vignette: >
|
|
|
|
%\VignetteIndexEntry{Introduction}
|
|
|
|
%\VignetteEngine{knitr::rmarkdown}
|
|
|
|
%\VignetteEncoding{UTF-8}
|
|
|
|
---
|
|
|
|
|
|
|
|
```{r, include = FALSE}
|
|
|
|
knitr::opts_chunk$set(
|
|
|
|
collapse = TRUE,
|
|
|
|
comment = "#>"
|
|
|
|
)
|
|
|
|
```
|
|
|
|
|
|
|
|
```{r setup}
|
|
|
|
library(REDCapCAST)
|
|
|
|
```
|
|
|
|
|
|
|
|
This vignette covers the included functions and basic functionality.
|
|
|
|
|
2023-04-13 12:15:34 +02:00
|
|
|
A dataset and a meta data file are provided with the package for demonstration of the functions.
|
2023-04-13 10:57:04 +02:00
|
|
|
|
2023-04-13 12:15:34 +02:00
|
|
|
## Splitting the dataset
|
2023-04-13 10:57:04 +02:00
|
|
|
|
|
|
|
```{r}
|
2023-04-13 12:15:34 +02:00
|
|
|
redcapcast_data |> gt::gt()
|
2023-04-13 10:57:04 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
```{r}
|
2023-04-13 12:15:34 +02:00
|
|
|
redcapcast_meta |> gt::gt()
|
2023-04-13 10:57:04 +02:00
|
|
|
```
|
|
|
|
```{r}
|
|
|
|
list <-
|
2023-04-13 12:15:34 +02:00
|
|
|
REDCapCAST::REDCap_split(records = redcapcast_data,
|
|
|
|
metadata = redcapcast_meta,
|
2023-04-13 10:57:04 +02:00
|
|
|
forms = "repeating")
|
|
|
|
str(list)
|
|
|
|
```
|
|
|
|
|
|
|
|
```{r}
|
|
|
|
list <-
|
2023-04-13 12:15:34 +02:00
|
|
|
REDCapCAST::REDCap_split(records = redcapcast_data,
|
|
|
|
metadata = redcapcast_meta,
|
2023-04-13 10:57:04 +02:00
|
|
|
forms = "all")
|
|
|
|
str(list)
|
|
|
|
```
|
|
|
|
|
|
|
|
## Reading data from REDCap
|
|
|
|
|
2023-04-13 12:15:34 +02:00
|
|
|
This function wraps all the above demonstrated function to get the dataset, the metadata, apply the `REDCap_split`function and then a bit of cleaning.
|
|
|
|
|
|
|
|
The function works verysimilarly as the `REDCapR::redcap_read()`.
|
|
|
|
|
|
|
|
```{r eval=FALSE}
|
|
|
|
# read_redcap_tables(uri = "YOUR URI", token = "YOUR TOKEN")
|
|
|
|
|
|
|
|
# ds <- read_redcap_tables(uri = key_get("DB_URI"), token = key_get("cast_api"))
|
2023-04-13 10:57:04 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Pivotting to wider format
|
|
|
|
|
|
|
|
```{r}
|
2023-04-13 12:15:34 +02:00
|
|
|
# redcap_wider(ds)
|
2023-04-13 10:57:04 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|