Type: | Package |
Title: | Converting Weekly Data to Monthly Data |
Version: | 1.0.5 |
Date: | 2017-08-31 |
Description: | Converts weekly data to monthly data. Users can use three types of week formats: ISO week, epidemiology week (epi week) and calendar date. |
Depends: | R (≥ 3.4.0) |
License: | GPL-2 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 6.0.1 |
NeedsCompilation: | no |
Packaged: | 2017-08-31 16:03:59 UTC; s1666783 |
Author: | You Li [aut, cre] |
Maintainer: | You Li <You.Li2@ed.ac.uk> |
Repository: | CRAN |
Date/Publication: | 2017-08-31 16:21:03 UTC |
Return the dates of a particular week
Description
Returns the dates of a particular week. The week can be defined by ISO week or epi week.
Usage
dateFromWeek(year, wkIndex, wkMethod = "ISO")
Arguments
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. |
Value
a vector of length 7, containing all the dates in the week, with the format of yyyy-mm-dd.
Author(s)
You Li
See Also
weekToMonth
Examples
dateFromWeek(year = 2000, wkIndex = 20)
dateFromWeek(year = 2009, wkIndex = 53)
dateFromWeek(year = 2015, wkIndex = 1, wkMethod = "epiSun")
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")
Weekly influenza cases in 18 countries, 2010-2015
Description
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.
Usage
weeklyFlu
Format
a data frame containing 5616 rows and 10 variables.
- country
country: Argentina, Australia, Brazil, Chile, China, Egypt, Germany, Ghana, Indonesia, Iran, Japan, Mongolia, Niger, Peru, Singapore, Thailand, Tanzania, Zambia
- whoRegion
WHO region
- fluRegion
influenza region
- year
year of data
- isoWeek
index of ISO week
- startDat
start date of the week
- endDat
end date of the week
- fluA
number of influenza A cases
- fluB
number of influenza B cases
- fluAll
number of influenza A+B cases