Package 'MMWRweek'

Title: Convert Dates to MMWR Day, Week, and Year
Description: The first day of any MMWR week is Sunday. MMWR week numbering is sequential beginning with 1 and incrementing with each week to a maximum of 52 or 53. MMWR week #1 of an MMWR year is the first week of the year that has at least four days in the calendar year. This package provides functionality to convert Dates to MMWR day, week, and year and the reverse.
Authors: Jarad Niemi <[email protected]>
Maintainer: Jarad Niemi <[email protected]>
License: GPL (>= 2) | file LICENSE
Version: 0.1.3
Built: 2025-03-09 03:10:12 UTC
Source: https://github.com/jarad/mmwrweek

Help Index


Finds the start date for the year associated with date.

Description

Finds the start date for the year associated with date.

Usage

get_start_date(date)

Arguments

date

vector which can be coerced to class Date

Value

Date vector for start date of MMWR year associated with date

Author(s)

Jarad Niemi [email protected]

See Also

start_date


MMWR day, week, and year

Description

This function returns the MMWR day, week, and year for the Date(s) provided.

Usage

MMWRweek(date)

Arguments

date

vector which can be coerced to class Date

Details

The first day of any MMWR week is Sunday. MMWR week numbering is sequential beginning with 1 and incrementing with each week to a maximum of 52 or 53. MMWR week #1 of an MMWR year is the first week of the year that has at least four days in the calendar year. For example, if January 1 occurs on a Sunday, Monday, Tuesday or Wednesday, the calendar week that includes January 1 would be MMWR week #1. If January 1 occurs on a Thursday, Friday, or Saturday, the calendar week that includes January 1 would be the last MMWR week of the previous year (#52 or #53). Because of this rule, December 29, 30, and 31 could potentially fall into MMWR week #1 of the following MMWR year.

Value

data.frame with elements MMWRday (of the week), MMWRweek, and MMWRyear

Author(s)

Jarad Niemi [email protected]

References

http://wwwn.cdc.gov/nndss/document/MMWR_Week_overview.pdf

See Also

MMWRweekday, MMWRweek2Date

Examples

y = as.Date(paste(1999:2011, "-12-31", sep = ""))
cbind(y, MMWRweek(y))

Convert MMWRweek to Date

Description

Computes the Date from the MMWR year, week, and day.

Usage

MMWRweek2Date(MMWRyear, MMWRweek, MMWRday = NULL)

Arguments

MMWRyear

numeric vector of years

MMWRweek

numeric vector of weeks

MMWRday

numeric vector of days, defaults to a vector of 1s

Value

Date vector of dates associated with MMWR year, week, and day

Author(s)

Jarad Niemi [email protected]

See Also

MMWRweek

Examples

MMWRweek2Date(MMWRyear=2015,MMWRweek=36,MMWRday=3)

Day of week according to MMWR

Description

This function returns the weekday of a given date according to MMWR.

Usage

MMWRweekday(date)

Arguments

date

vector which can be coerced to class Date

Value

vector of weekdays as a factor (first level is Sunday)

Author(s)

Sebastian Meyer [email protected]

See Also

MMWRweek

Examples

y <- as.Date(paste(1999:2011, "-12-31", sep = ""))
data.frame(date = format(y), MMWRweekday = MMWRweekday(y))

Find start date for a calendar year

Description

Finds the state date given a numeric calendar year

Usage

start_date(year)

Arguments

year

integer vector of four digit years

Value

Date vector for January 1st of the calendar year

Author(s)

Jarad Niemi [email protected]

See Also

get_start_date