new working version with major updates

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-12-17 11:30:17 +01:00
commit e4633421aa
No known key found for this signature in database
16 changed files with 1678 additions and 85 deletions

60
man/cut-variable.Rd Normal file
View file

@ -0,0 +1,60 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cut-variable-dates.R
\name{cut-variable}
\alias{cut-variable}
\alias{cut_variable_ui}
\alias{cut_variable_server}
\alias{modal_cut_variable}
\alias{winbox_cut_variable}
\title{Module to Convert Numeric to Factor}
\usage{
cut_variable_ui(id)
cut_variable_server(id, data_r = reactive(NULL))
modal_cut_variable(
id,
title = i18n("Convert Numeric to Factor"),
easyClose = TRUE,
size = "l",
footer = NULL
)
winbox_cut_variable(
id,
title = i18n("Convert Numeric to Factor"),
options = shinyWidgets::wbOptions(),
controls = shinyWidgets::wbControls()
)
}
\arguments{
\item{id}{Module ID.}
\item{data_r}{A \code{\link[shiny:reactive]{shiny::reactive()}} function returning a \code{data.frame}.}
\item{title}{An optional title for the dialog.}
\item{easyClose}{If \code{TRUE}, the modal dialog can be dismissed by
clicking outside the dialog box, or be pressing the Escape key. If
\code{FALSE} (the default), the modal dialog can't be dismissed in those
ways; instead it must be dismissed by clicking on a \code{modalButton()}, or
from a call to \code{\link[shiny:removeModal]{removeModal()}} on the server.}
\item{size}{One of \code{"s"} for small, \code{"m"} (the default) for medium,
\code{"l"} for large, or \code{"xl"} for extra large. Note that \code{"xl"} only
works with Bootstrap 4 and above (to opt-in to Bootstrap 4+,
pass \code{\link[bslib:bs_theme]{bslib::bs_theme()}} to the \code{theme} argument of a page container
like \code{\link[shiny:fluidPage]{fluidPage()}}).}
\item{footer}{UI for footer. Use \code{NULL} for no footer.}
\item{options}{List of options, see \code{\link[shinyWidgets:wbOptions]{wbOptions()}}.}
\item{controls}{List of controls, see \code{\link[shinyWidgets:wbControls]{wbControls()}}.}
}
\value{
A \code{\link[shiny:reactive]{shiny::reactive()}} function returning the data.
}
\description{
This module contain an interface to cut a numeric into several intervals.
}

55
man/cut.Rd Normal file
View file

@ -0,0 +1,55 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cut-variable-dates.R
\name{cut.hms}
\alias{cut.hms}
\alias{cut.POSIXt}
\alias{cut.POSIXct}
\alias{cut.Date}
\title{Title}
\usage{
\method{cut}{hms}(x, breaks, ...)
\method{cut}{POSIXt}(
x,
breaks,
right = FALSE,
include.lowest = TRUE,
start.on.monday = TRUE,
...
)
\method{cut}{POSIXct}(
x,
breaks,
right = FALSE,
include.lowest = TRUE,
start.on.monday = TRUE,
...
)
\method{cut}{Date}(x, breaks, start.on.monday = TRUE, ...)
}
\arguments{
\item{x}{an object inheriting from class "POSIXct"}
\item{...}{passed on}
}
\value{
factor
}
\description{
Title
}
\examples{
readr::parse_time(c("01:00:20", "03:00:20", "01:20:20", "08:20:20", "21:20:20", "03:02:20")) |> cut(2)
readr::parse_time(c("01:00:20", "03:00:20", "01:20:20", "08:20:20", "21:20:20", "03:02:20")) |> cut("min")
readr::parse_time(c("01:00:20", "03:00:20", "01:20:20", "08:20:20", "21:20:20", "03:02:20")) |> cut(breaks = "hour")
readr::parse_time(c("01:00:20", "03:00:20", "01:20:20", "08:20:20", "21:20:20", "03:02:20")) |> cut(breaks = hms::as_hms(c("01:00:00", "03:01:20", "9:20:20")))
d_t <- readr::parse_time(c("01:00:20", "03:00:20", "01:20:20", "03:02:20", NA))
f <- d_t |> cut(2)
readr::parse_time(c("01:00:20", "03:00:20", "01:20:20", "03:02:20", NA)) |> cut(breaks = lubridate::as_datetime(c(hms::as_hms(levels(f)), hms::as_hms(max(d_t, na.rm = TRUE) + 1))), right = FALSE)
readr::parse_datetime(c("1992-02-01 01:00:20", "1992-02-06 03:00:20", "1992-05-01 01:20:20", "1992-09-01 08:20:20", "1999-02-01 21:20:20", "1992-12-01 03:02:20")) |> cut(2)
readr::parse_datetime(c("1992-02-01 01:00:20", "1992-02-06 03:00:20", "1992-05-01 01:20:20", "1992-09-01 08:20:20", "1999-02-01 21:20:20", "1992-12-01 03:02:20")) |> cut(breaks="weekday")
as.Date(c("1992-02-01 01:00:20", "1992-02-06 03:00:20", "1992-05-01 01:20:20", "1992-09-01 08:20:20", "1999-02-01 21:20:20", "1992-12-01 03:02:20")) |> cut(2)
as.Date(c("1992-02-01 01:00:20", "1992-02-06 03:00:20", "1992-05-01 01:20:20", "1992-09-01 08:20:20", "1999-02-01 21:20:20", "1992-12-01 03:02:20")) |> cut(breaks="weekday")
}

24
man/is_any_class.Rd Normal file
View file

@ -0,0 +1,24 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cut-variable-dates.R
\name{is_any_class}
\alias{is_any_class}
\title{Test class}
\usage{
is_any_class(data, class.vec)
}
\arguments{
\item{data}{data}
\item{class.vec}{vector of class names to test}
}
\value{
factor
}
\description{
Test class
}
\examples{
vapply(REDCapCAST::redcapcast_data, \(.x){
is_any_class(.x, c("hms", "Date", "POSIXct", "POSIXt"))
}, logical(1))
}

20
man/is_datetime.Rd Normal file
View file

@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cut-variable-dates.R
\name{is_datetime}
\alias{is_datetime}
\title{Test is date/datetime/time}
\usage{
is_datetime(data)
}
\arguments{
\item{data}{data}
}
\value{
factor
}
\description{
Test is date/datetime/time
}
\examples{
vapply(REDCapCAST::redcapcast_data, is_datetime, logical(1))
}

View file

@ -5,13 +5,15 @@
\alias{m_redcap_readServer}
\title{Shiny module to browser and export REDCap data}
\usage{
m_redcap_readUI(id)
m_redcap_readUI(id, include_title = TRUE)
m_redcap_readServer(id, output.format = "df")
m_redcap_readServer(id, output.format = c("df", "teal", "list"))
}
\arguments{
\item{id}{Namespace id}
\item{include_title}{logical to include title}
\item{output.format}{data.frame ("df") or teal data object ("teal")}
}
\value{