fix_levels {clickR} | R Documentation |
Fix levels
Description
Fixes levels of a factor
Usage
fix_levels(
data,
factor_name,
method = "dl",
levels = NULL,
plot = FALSE,
k = ifelse(!is.null(levels), length(levels), 2),
track = TRUE,
...
)
Arguments
data |
data.frame with the factor to fix |
factor_name |
Name of the factor to fix (as character) |
method |
Method from stringdist package to estimate distances |
levels |
Optional vector with the levels names. If "auto", levels are assigned based on frequency |
plot |
Optional: Plot cluster dendrogram? |
k |
Number of levels for clustering |
track |
Keep track of changes? |
... |
Further parameters passed to stringdist::stringdistmatrix function |
Examples
mydata <- data.frame(factor1=factor(c("Control", "Treatment", "Tretament", "Tratment", "treatment",
"teatment", "contrl", "cntrol", "CONTol", "not available", "na")))
fix_levels(mydata, "factor1", k=4, plot=TRUE) #Chose k to select matching levels
fix_levels(mydata, "factor1", levels=c("Control", "Treatment"), k=4)
[Package clickR version 0.9.39 Index]