count_vars_sep: Separate and Count Variables to DF

View source: R/count_vars_sep.R

count_vars_sepR Documentation

Separate and Count Variables to DF

Description

Separate texts in a variables using a separator sep into rows, trim white space, counts each variables, and return list of counted data frames.

Usage

count_vars_sep(data, vars = NULL, sep = ",", convert = FALSE, sort = TRUE)

Arguments

data

A Data Frame

vars

(Character) A Character of variables to count. If NULL, count all variables in the data frame.

sep

A separator of texts

convert

If TRUE will automatically run type.convert() on the key column. This is useful if the column types are actually numeric, integer, or logical.

sort

If TRUE, will show the largest groups at the top.

Value

a named list of data frames (named as counted variable names)

Examples

df <- data.frame(
  x = 1:3,
  y = c("a", "d,e,f", "g,h"),
  z = c("1", "2, 3, 4", "5, 6, 7")
 )
count_vars_sep(df, sep = ",")

Lightbridge-KS/lbx documentation built on Dec. 4, 2024, 2:53 a.m.