Package 'wktmo'

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

Help Index


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")

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

Source

http://www.who.int/influenza/gisrs_laboratory/flunet/en/


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 datStart.

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")