Title: | Converting Weekly Data to Monthly Data |
---|---|
Description: | Converts weekly data to monthly data. Users can use three types of week formats: ISO week, epidemiology week (epi week) and calendar date. |
Authors: | You Li [aut, cre] |
Maintainer: | You Li <[email protected]> |
License: | GPL-2 |
Version: | 1.0.5 |
Built: | 2025-03-04 04:47:04 UTC |
Source: | https://github.com/leoly2017/wktmo |
Returns the dates of a particular week. The week can be defined by ISO week or epi week.
dateFromWeek(year, wkIndex, wkMethod = "ISO")
dateFromWeek(year, wkIndex, wkMethod = "ISO")
year |
a value for the year. |
wkIndex |
a value for the week index of the year. |
wkMethod |
a character string for the week-counting method. 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. |
a vector of length 7, containing all the dates in the week, with the format of yyyy-mm-dd.
You Li
weekToMonth
dateFromWeek(year = 2000, wkIndex = 20) dateFromWeek(year = 2009, wkIndex = 53) dateFromWeek(year = 2015, wkIndex = 1, wkMethod = "epiSun")
dateFromWeek(year = 2000, wkIndex = 20) dateFromWeek(year = 2009, wkIndex = 53) dateFromWeek(year = 2015, wkIndex = 1, wkMethod = "epiSun")
A dataset containing weekly influenza cases, including influenza A, influenza B and influenza A+B, in 18 countries during 2010-2015. Data are from FluNet, a global web-based tool for influenza virological surveillance.
weeklyFlu
weeklyFlu
a data frame containing 5616 rows and 10 variables.
country: Argentina, Australia, Brazil, Chile, China, Egypt, Germany, Ghana, Indonesia, Iran, Japan, Mongolia, Niger, Peru, Singapore, Thailand, Tanzania, Zambia
WHO region
influenza region
year of data
index of ISO week
start date of the week
end date of the week
number of influenza A cases
number of influenza B cases
number of influenza A+B cases
http://www.who.int/influenza/gisrs_laboratory/flunet/en/
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.
weekToMonth(wkdata, year = NULL, wkIndex = NULL, wkMethod = "ISO", datStart = NULL, format = "%d-%m-%Y")
weekToMonth(wkdata, year = NULL, wkIndex = NULL, wkMethod = "ISO", datStart = NULL, format = "%d-%m-%Y")
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 |
a dataframe containing two column vectors: yearMonth
and
value
.
You Li
dateFromWeek
# 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")
# 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")