View source: R/ordered_fin_qtr.R
ordered_fin_qtr | R Documentation |
Creates factor variable from financial quarter to preserve correct ordering in wide reshape of data.
ordered_fin_qtr(data, quarter_in_long_format)
data |
A dataframe |
quarter_in_long_format |
A string variable giving long financial year
created using |
A dataframe with a new variable 'fin_qtr_ftr'
fy_long
ordered_m_y
dat <- data.frame(sample_date = lubridate::dmy("01/01/2001"))
dat$sample_fy <- fy_long(dat$sample_date)
dat <- ordered_fin_qtr(dat, "sample_fy")
class(dat$fin_qtr_ftr)
levels(dat$fin_qtr_ftr)
dat <- data.frame(sample_date = lubridate::dmy("01/01/2001"))
dat$sample_fq <- fq_long(dat$sample_date)
dat <- ordered_fin_qtr(dat, "sample_fq")
class(dat$fin_qtr_ftr)
levels(dat$fin_qtr_ftr)
dat <- data.frame(sample_date = c(lubridate::dmy("01/01/2001"),
lubridate::dmy("01/04/2001"),
lubridate::dmy("01/07/2001"),
lubridate::dmy("01/10/2001"),
lubridate::dmy("01/01/2002")
))
dat$sample_fq <- fq_long(dat$sample_date)
dat <- ordered_fin_qtr(dat, "sample_fq")
class(dat$fin_qtr_ftr)
levels(dat$fin_qtr_ftr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.