# based on minimum frequency unique values
state_region <- as.character(state.region)
recode2other(state_region, freq.min = 13) # freq.min as a count
recode2other(state_region, freq.min = 0.26, prop = TRUE) # freq.min as a proportion
recode2other(state_region, freq.min = 13, other.nm = "_blank_")
recode2other(state_region, freq.min = 13,
other.nm = NA) # allows for other.nm to be NA
recode2other(state_region, freq.min = 13,
extra.nm = "South") # add an extra unique value to recode
recode2other(state_region, freq.min = 13,
inclusive = FALSE) # recodes "West" to "other"
# based on user given unique values
recode2other(state_region, freq.min = 0,
extra.nm = c("South","West")) # recodes manually rather than by freq.min
# current version does NOT allow for NA to be a unique value that is converted to other
state_region2 <- c(NA, state_region, NA)
recode2other(state_region2, freq.min = 13) # NA remains in the character vector
recode2other(state_region2, freq.min = 0,
extra.nm = c("South","West",NA)) # NA remains in the character vector
Run the code above in your browser using DataLab