combine_year_quarter: Combine the Year and Quarter Column into '2021-Q1' Form

Description Usage Arguments Value Examples

View source: R/other_utils.R

Description

This function will combine the numeric or factor column of year and quarter into the form of "2021-Q1" whcih reffers to the year 2021 and the first quarter.

Usage

1
2
3
4
5
6
7
combine_year_quarter(
  data,
  year_name = "year",
  quarter_name = "quarter",
  simple = TRUE,
  quarter_trans = antgreens::quarter_readable
)

Arguments

data

a data frame.

year_name

character, default 'year'. It is the column name representing the year.

quarter_name

character, default 'quarter'. It is the column name representing the quarter.

simple

logical, default TRUE. If set 'TRUE' then use number as quarter name.

quarter_trans

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

Value

a data frame with column timeline and without column year_name and quarter_name.

Examples

1
2
df <- data.frame(a = 2017:2021, b = c(1,2,2,4,3))
combine_year_quarter(df, year_name = 'a', quarter_name = 'b')

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