weekToMonth: Convert weekly data to monthly data

Description Usage Arguments Value Author(s) See Also Examples

View source: R/weekToMonth.R

Description

Converts weekly data to monthly data. The start week or date is needed along with the data. The start week can be defined by ISO week or epi week.

Usage

1
2
weekToMonth(wkdata, year = NULL, wkIndex = NULL, wkMethod = "ISO",
  datStart = NULL, format = "%d-%m-%Y")

Arguments

wkdata

a numeric vector for weekly data to be converted.

year

a value for the year of the start of the data.

wkIndex

a value for the week index of the start of the data if a week-counting method is used.

wkMethod

a character string for the week-counting methods. Default is "ISO" for ISO-week; other options are "epiSat", "epiSun" and "epiMon" for epi-week method defining Saturday, Sunday and Monday as the firstday in a week, respectively. In addition, users also have the option of specifying the start date of the data by "startDat" method.

datStart

a character string for the start date of the data. If left blank, the date generated from the week-counting method will be applied.

format

a character string specifying the input formate for datStart.

Value

a dataframe containing two column vectors: yearMonth and value.

Author(s)

You Li

See Also

dateFromWeek

Examples

1
2
3
4
5
6
7
8
# extract data
data(weeklyFlu)
# subset data of interest, e.g. to convert weekly influenza A cases in China
weeklyData <- weeklyFlu$fluA[weeklyFlu$country == "China"]
# convert weekly data to monthly data;
# these two input methods below will return the same results.
monthlyData <- weekToMonth(weeklyData, year = 2010, wkIndex = 1, wkMethod = "ISO")
monthlyData <- weekToMonth(weeklyData, datStart = "04-01-2010", wkMethod = "startDat")

Example output



wktmo documentation built on Aug. 31, 2017, 5:02 p.m.