mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2026-06-19 04:27:30 +02:00
added option to specify categorical variables and print input classes
This commit is contained in:
parent
9c0cb53862
commit
069d6d79fa
4 changed files with 75 additions and 4 deletions
22
R/helpers.R
22
R/helpers.R
|
|
@ -94,3 +94,25 @@ read_input <- function(file, consider.na = c("NA", '""', "")) {
|
|||
argsstring2list <- function(string){
|
||||
eval(parse(text = paste0("list(", string, ")")))
|
||||
}
|
||||
|
||||
|
||||
#' Factorize variables in data.frame
|
||||
#'
|
||||
#' @param data data.frame
|
||||
#' @param vars variables to force factorize
|
||||
#'
|
||||
#' @return data.frame
|
||||
#' @export
|
||||
factorize <- function(data,vars){
|
||||
if (!is.null(vars)) {
|
||||
data |>
|
||||
dplyr::mutate(
|
||||
dplyr::across(
|
||||
dplyr::all_of(vars),
|
||||
REDCapCAST::as_factor
|
||||
)
|
||||
)
|
||||
} else {
|
||||
data
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue