REDCapCAST/vignettes/REDCapCAST.Rmd

61 lines
1.3 KiB
Plaintext
Raw Normal View History

2023-04-13 10:57:04 +02:00
---
2024-11-18 10:54:24 +01:00
title: "REDCapCAST"
2023-04-13 10:57:04 +02:00
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.
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
## Splitting the dataset
2023-04-13 10:57:04 +02:00
```{r}
redcapcast_data |> gt::gt()
2023-04-13 10:57:04 +02:00
```
```{r}
redcapcast_meta |> gt::gt()
2023-04-13 10:57:04 +02:00
```
```{r}
list <-
2024-02-27 13:20:21 +01:00
REDCap_split(
records = redcapcast_data,
metadata = redcapcast_meta,
forms = "all"
) |>
sanitize_split()
2023-04-13 10:57:04 +02:00
str(list)
```
## Reading data from REDCap
2023-04-14 11:47:23 +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. It just cuts outs all the steps for an easier approach.
2023-04-14 11:47:23 +02:00
The function works very similar to the `REDCapR::redcap_read()` in allowing to specify fields, events and forms for export instead of exporting the whole database and filtering afterwards. I believe this is a better and safer, focused approach.
```{r eval=FALSE}
# read_redcap_tables(uri = "YOUR URI", token = "YOUR TOKEN")
2023-04-13 10:57:04 +02:00
```
## Pivotting to wider format
```{r}
2024-02-06 14:16:09 +01:00
redcap_wider(list) |> str()
2023-04-13 10:57:04 +02:00
```