weekToMonth {wktmo} | R Documentation |
Convert weekly data to monthly data
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
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 |
Value
a dataframe containing two column vectors: yearMonth
and
value
.
Author(s)
You Li
See Also
dateFromWeek
Examples
# 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")