MyNixOS website logo
Description

Converting Weekly Data to Monthly Data.

Converts weekly data to monthly data. Users can use three types of week formats: ISO week, epidemiology week (epi week) and calendar date.

wktmo

Introduction

Researchers working with weekly time series data may have the need to convert the data from weekly basis to monthly basis. However, it is challenging to allocate weeks to months since the dates of weeks are not fixed in different calendar years, especially when a week has dates in two months.

The goal of wktmo is to convert weekly data to monthly data. For weeks that have dates in two months, the input value will be allocated evenly to the the dates. For example, if a week contains four days in January and three days in February, then four sevenths will go to January and three sevens will go to February. For weekly data, three types of week formats are accepted: ISO week, epi week and calendar date.

Installation

wktmo is built under R 3.4.0. For a stable version, you can install wktmo from CRAN with:

install.packages("wktmo")

For a development version, you can install wktmo from Github with:

install.packages("devtools")
devtools::install_github("leoly2017/wktmo")

Example

This is a basic example which shows you how to convert real-world weekly data to monthly data. weeklyFlu is a dataset containing weekly influenza cases, including influenza A, influenza B and influenza A+B, of 18 countries during 2010-2015; data are from FluNet, a global web-based tool for influenza virological surveillance. Use help(weeklyFlu) for more information.

library(wktmo)
# 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.
# input 1: the start year and wkIndex
monthlyData <- weekToMonth(weeklyData, year = 2010, wkIndex = 1, wkMethod = "ISO")
# display only first 15 rows of the results
yearMonthvalue
2010-0127559
2010-026783
2010-037656
2010-042539
2010-052068
2010-061662
2010-076150
2010-0822130
2010-0937055
2010-1019664
2010-119041
2010-1212398
2011-0139581
2011-0233775
2011-039409
# input 2: the start date, same results
monthlyData <- weekToMonth(weeklyData, datStart = "04-01-2010", wkMethod = "startDat")
yearMonthvalue
2010-0127559
2010-026783
2010-037656
2010-042539
2010-052068
2010-061662
2010-076150
2010-0822130
2010-0937055
2010-1019664
2010-119041
2010-1212398
2011-0139581
2011-0233775
2011-039409

Suggestions and reports of bugs

Suggestions and reports of bugs are always welcome. If there are any, contact You Li ([email protected]).

Updates

wktmo 1.0.4

Minor changes

Small changes in README file.

wktmo 1.0.3

Major Changes

Add a real-world dataset, weeklyFlu.

Replace examples with new examples using data in weeklyFlu.

wktmo 1.0.2

Minor Changes

Improvement on formmatting of examples.

wktmo 1.0.1

First published on CRAN.

Minor Changes

Revisions of DESCRIPTION file.

wktmo 1.0.0

First submission to CRAN.

Metadata

Version

1.0.5

License

Unknown

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows