factor_dims: Make Columns As Factor

Description Usage Arguments Value Examples

View source: R/factor_utils.R

Description

Make Columns As Factor

Usage

1
2
3
4
5
6
7
factor_dims(
  dataset,
  ...,
  funcs = list(),
  quarter_readable = TRUE,
  quarter_trans = antgreens::quarter_readable
)

Arguments

dataset

data frame with readable quarter column or year/province/category/product/drug/timeline column.

...

dimensions to be made as factor.

funcs

named list of custome factor function

quarter_readable

logical, default TRUE. If set TRUE then make quarter column readable and as a factor.

quarter_trans

list containing 4 characters and the names of each element is 1, 2, 3, 4, which represents the four quarters.

Value

data frame with factor column. And the order of quarter is depends on the order of quarter_readable; the order of year is depends on the number of year; the order of province, category product and drug are depends on the dictionary order of character.

Examples

1
2
data <- data.frame(year = 2016:2019, quarter = c(1,2,3,4))
factor_dims(data, year, quarter, quarter_trans = list(`1`='a',`2`='b',`3`='c',`4`='d'))

YuanchenZhu2020/antgreens documentation built on Dec. 18, 2021, 8:20 p.m.