Skip to content

Commit

Permalink
Update docs with many families of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
billdenney committed Nov 28, 2022
1 parent 26de1b3 commit 06be66b
Show file tree
Hide file tree
Showing 37 changed files with 659 additions and 36 deletions.
10 changes: 6 additions & 4 deletions R/c_to_n.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
#' values. For data.frames and similar, the same class of object with numeric
#' versions of columns added.
#' @export
#' @family Number management and conversion
c_to_n <- function(x, ...)
UseMethod("c_to_n")

#' @describeIn c_to_n The main workhorse function of c_to_n
#'
#'
#' @param pattern_numeric A regular expression to detect numeric values.
#' @param verbose Report detailed status of .
#' @details The main workhorse function is c_to_n.character, and it will
#' recognize the following numeric types:
#'
#'
#' \itemize{
#' \item{positive or negative (with optional sign) for all classes}
#' \item{integers with an optional decimal point after the number}
Expand All @@ -25,10 +26,11 @@ c_to_n <- function(x, ...)
#' \item{scientific notation with any of the prior numeric types as the
#' coefficient and an optional sign before the exponent}
#' }
#'
#'
#' Spaces at the beginning and end are removed with `trimws()`
#'
#'
#' @export
#' @family Number management and conversion
c_to_n.character <- function(x, ...,
pattern_numeric=
paste0(
Expand Down
4 changes: 4 additions & 0 deletions R/date_conversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @param ... Additional arguments passed to \code{lubridate::ymd_hms}
#' @return The data with the date converted. Note that all dates will be
#' returned as POSIXct objects, so partial dates will appear as the
#' @family Date management and conversion
#' @export
sdtm_dtc_to_datetime <- function(x, ...) {
UseMethod("sdtm_dtc_to_datetime")
Expand Down Expand Up @@ -61,6 +62,7 @@ sdtm_dtc_to_datetime.data.frame <- function(x, date_col_pattern="DTC$", truncate
#' @return An SDTM-formatted ISO8601 date-time with "UN:UN:UN" if the time is
#' `NA`. If all inputs are `NA`, then the output is also `NA`.
#' @export
#' @family Date management and conversion
#' @importFrom dplyr case_when
#' @importFrom lubridate format_ISO8601
generate_dtc <- function(datetime=NULL, date=NULL, time=NULL, early_hour="05", assume_24_hr_time=FALSE) {
Expand Down Expand Up @@ -156,6 +158,7 @@ generate_dtc <- function(datetime=NULL, date=NULL, time=NULL, early_hour="05", a
#' dateany_to_date(as.Date("2022-01-02"))
#' dateany_to_date(as.POSIXct("2022-01-02T03:04")) # the time part is still gone
#' @export
#' @family Date management and conversion
dateany_to_date <- function(x) {
if (is.character(x)) {
pattern_date <- "^(158[3-9]|159[0-9]|1[6-9][0-9]{2}|[2-9][0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(?:T.*)?$"
Expand Down Expand Up @@ -193,6 +196,7 @@ dateany_to_date <- function(x) {
#' @examples
#' make_dy(c("2022-01-02", "2022-01-03", "2022-01-04"), "2022-01-03")
#' @export
#' @family Date management and conversion
make_dy <- function(dates, refdt) {
stopifnot(length(refdt) %in% c(1, length(dates)))
dates <- dateany_to_date(dates)
Expand Down
3 changes: 2 additions & 1 deletion R/detect_domain.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#' Detect the SDTM or ADaM domain of a dataset (possibly via filename)
#'
#'
#' @param x The data
#' @param filename The filename associated with \code{x}
#' @param verbose Report domain detected and detection method?
#' @return A character scalar with the name of the domain
#' @export
#' @family Domain detection
detect_domain <- function(x, filename, verbose=TRUE) {
if ("RELID" %in% names(x)) {
return("RELREC")
Expand Down
1 change: 1 addition & 0 deletions R/first_dose.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' @importFrom dplyr is_grouped_df group_by_at rename_at summarize_at
#' @importFrom lubridate is.POSIXt ymd_hms
#' @export
#' @family Date management and conversion
sdtm_first_dose <- function(x, ...)
UseMethod("sdtm_first_dose")

Expand Down
1 change: 1 addition & 0 deletions R/import_sdtm.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#' one file with the same name from different directories or multiple versions
#' of the same file.
#' @export
#' @family Data import
import_sdtm <- function(path,
extension_choice = c(".sas7bdat", ".xpt"),
ignore_case = TRUE,
Expand Down
Loading

0 comments on commit 06be66b

Please sign in to comment.