mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2026-06-19 13:17:30 +02:00
all data parsing and formatting has been seperated in individual functions
This commit is contained in:
parent
4911d4dbc8
commit
ea08a2066f
7 changed files with 362 additions and 85 deletions
29
man/var2fct.Rd
Normal file
29
man/var2fct.Rd
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/ds2dd_detailed.R
|
||||
\name{var2fct}
|
||||
\alias{var2fct}
|
||||
\title{Convert vector to factor based on threshold of number of unique levels}
|
||||
\usage{
|
||||
var2fct(data, unique.n)
|
||||
}
|
||||
\arguments{
|
||||
\item{data}{vector or data.frame column}
|
||||
|
||||
\item{unique.n}{threshold to convert class to factor}
|
||||
}
|
||||
\value{
|
||||
vector
|
||||
}
|
||||
\description{
|
||||
This is a wrapper of forcats::as_factor, which sorts numeric vectors before
|
||||
factoring, but levels character vectors in order of appearance.
|
||||
}
|
||||
\examples{
|
||||
sample(seq_len(4), 20, TRUE) |>
|
||||
var2fct(6) |>
|
||||
summary()
|
||||
sample(letters, 20) |>
|
||||
var2fct(6) |>
|
||||
summary()
|
||||
sample(letters[1:4], 20, TRUE) |> var2fct(6)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue