New function to export redcap data with labels

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-11-26 14:46:11 +01:00
commit 21c2dc0444
No known key found for this signature in database
6 changed files with 228 additions and 3 deletions

View file

@ -4,7 +4,7 @@
\name{REDCapCAST-package}
\alias{REDCapCAST}
\alias{REDCapCAST-package}
\title{REDCapCAST: REDCap Castellated Data Handling and Metadata Casting}
\title{REDCapCAST: REDCap Metadata Casting and Castellated Data Handling}
\description{
\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}}

View file

@ -16,5 +16,5 @@ logical
Check if vector is all NA
}
\examples{
rep(NA,4) |> all_na()
rep(NA, 4) |> all_na()
}

View file

@ -65,7 +65,8 @@ c(1, 4, 3, "A", 7, 8, 1) |> as_factor()
structure(c(1, 2, 3, 2, 10, 9),
labels = c(Unknown = 9, Refused = 10)
) |>
as_factor() |> dput()
as_factor() |>
dput()
structure(c(1, 2, 3, 2, 10, 9),
labels = c(Unknown = 9, Refused = 10),

22
man/clean_field_label.Rd Normal file
View file

@ -0,0 +1,22 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/easy_redcap.R
\name{clean_field_label}
\alias{clean_field_label}
\title{Very simple function to remove rich text formatting from field label
and save the first paragraph ('<p>...</p>').}
\usage{
clean_field_label(data)
}
\arguments{
\item{data}{field label}
}
\value{
character vector
}
\description{
Very simple function to remove rich text formatting from field label
and save the first paragraph ('<p>...</p>').
}
\examples{
clean_field_label("<div class=\"rich-text-field-label\"><p>Fazekas score</p></div>")
}

View file

@ -0,0 +1,38 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/easy_redcap.R
\name{read_redcap_labelled}
\alias{read_redcap_labelled}
\title{REDCap read function to preserve field labels and all factor levels}
\usage{
read_redcap_labelled(
uri,
token,
records = NULL,
fields = NULL,
events = NULL,
forms = NULL,
split_forms = "all"
)
}
\arguments{
\item{uri}{REDCap database API uri}
\item{token}{API token}
\item{records}{records to download}
\item{fields}{fields to download}
\item{events}{events to download}
\item{forms}{forms to download}
\item{split_forms}{Whether to split "repeating" or "all" forms, default is
"all".}
}
\value{
data.frame or list
}
\description{
This works very much as `read_redcap_tables()` and might end up there
}