Learn R Programming

dint (version 2.0.0)

format_yw: Coerce and Format to Year-Isoweek Strings

Description

Coerce and Format to Year-Isoweek Strings

Usage

format_yw(x, w = NULL, format = "%Y-W%W")

Arguments

x, w

Two integer (vectors). w is optional and the interpretation of x will depend on whether w is supplied or not:

  • if only x is supplied, x will be passed to as_date_yw() (e.g. x = 201604 means 4th isoweek of 2016)

  • if x and w are supplied, x is interpreted as year and w as week.

format

A format that uses a subset of the same placeholders as base::strptime():

%Y Year with century (the full year)
%y Year without century (the last two digits of the year)
%m Month as a decimal numbers (01-12)
%B Full month name

Not all placeholders are supported for all date_xx subclasses. Literal % can be escaped with "%%" (as in base::sprintf()).

Value

a character vector

Formatting shorthands

Format shorthand functions in the form of format_y*_[preset]() directly apply formatting presets to anything that can be coerced to a date_xx. This is notably handy as they can be used as a labelling function for ggplot2 axes (see vignette("dint"))

See Also

format.date_yw()

Other coerce and format functions: format_ym, format_yq

Examples

Run this code
# NOT RUN {
format_yw(2015, 5)
format_yw(201505, format = "%Y.%W")
format_yw(as_date_yw(201505), format = "%y.%W")

# }

Run the code above in your browser using DataLab