three new functions and new version

This commit is contained in:
Andreas Gammelgaard Damsbo 2023-07-04 16:03:06 +02:00
commit 8bd4d9ade7
11 changed files with 415 additions and 49 deletions

32
man/d2w.Rd Normal file
View file

@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.r
\name{d2w}
\alias{d2w}
\title{Convert single digits to words}
\usage{
d2w(x, lang = "en", neutrum = FALSE, everything = FALSE)
}
\arguments{
\item{x}{data. Handle vectors, data.frames and lists}
\item{lang}{language. Danish (da) and English (en), Default is "en"}
\item{neutrum}{for numbers depending on counted word}
\item{everything}{flag to also split numbers >9 to single digits}
}
\value{
returns characters in same format as input
}
\description{
Convert single digits to words
}
\examples{
d2w(c(2:8,21))
d2w(data.frame(2:7,3:8,1),lang="da",neutrum=TRUE)
## If everything=T, also larger numbers are reduced.
## Elements in the list are same length as input
d2w(list(2:8,c(2,6,4,23),2), everything=TRUE)
}

49
man/ds2dd.Rd Normal file
View file

@ -0,0 +1,49 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ds2dd.R
\name{ds2dd}
\alias{ds2dd}
\title{Data set to data dictionary function}
\usage{
ds2dd(
ds,
record.id = "record_id",
form.name = "basis",
field.type = "text",
field.label = NULL,
include.column.names = FALSE,
metadata = names(redcapcast_meta)
)
}
\arguments{
\item{ds}{data set}
\item{record.id}{name or column number of id variable, moved to first row of
data dictionary, character of integer. Default is "record_id".}
\item{form.name}{vector of form names, character string, length 1 or length
equal to number of variables. Default is "basis".}
\item{field.type}{vector of field types, character string, length 1 or length
equal to number of variables. Default is "text.}
\item{field.label}{vector of form names, character string, length 1 or length
equal to number of variables. Default is NULL and is then identical to field
names.}
\item{include.column.names}{Flag to give detailed output including new
column names for original data set for upload.}
\item{metadata}{Metadata column names. Default is the included
REDCapCAST::redcapcast_data.}
}
\value{
data.frame or list of data.frame and vector
}
\description{
Migrated from stRoke ds2dd(). Fits better with the functionality of
'REDCapCAST'
}
\examples{
redcapcast_data$record_id <- seq_len(nrow(redcapcast_data))
ds2dd(redcapcast_data, include.column.names=TRUE)
}

30
man/strsplitx.Rd Normal file
View file

@ -0,0 +1,30 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.r
\name{strsplitx}
\alias{strsplitx}
\title{Extended string splitting}
\usage{
strsplitx(x, split, type = "classic", perl = FALSE, ...)
}
\arguments{
\item{x}{data}
\item{split}{delimiter}
\item{type}{Split type. Can be c("classic", "before", "after", "around")}
\item{perl}{perl param from strsplit()}
\item{...}{additional parameters are passed to base strsplit handling splits}
}
\value{
list
}
\description{
Can be used as a substitute of the base function. Main claim to fame is
easing the split around the defined delimiter, see example.
}
\examples{
test <- c("12 months follow-up", "3 steps", "mRS 6 weeks", "Counting to 231 now")
strsplitx(test,"[0-9]",type="around")
}