Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

R Package for Acquiring and Processing Data from Japan Institute for Health Security

License

NotificationsYou must be signed in to change notification settings

TomonoriHoshi/jpinfect

CRAN statusstatusTotal downloadsCRAN downloadsR-CMD-check

Thejpinfect package provides tools for acquiring and processing notifiable infectious disease data in Japan. It is designed to help researchers, public health officials and developers access, clean, and manipulate data. This package aims to streamline data analysis processes while enabling reproducible research in public health and epidemiology.

Key features include:

  • Access ready-to-use datasets for immediate analysis.

  • Automate the downloading of raw data files for notifiable infectious disease, provided by the government

  • Tools for organising and renaming data files when importing into R

  • Combine segmented data files into a single dataset

  • Compatibility with epidemiological analysis and reporting workflows.

Data sourced from the Japan Institute for Health Security (JIHS). Data provided in this package is subject to their open data policy (Government Standard Terms of Use v1.0). For further details, seedata usage terms. This library is independently developed and is not affiliated with any government entity.

Installation

Thejpinfect package can be installed from either CRAN or GitHub using theremotes package. Through the Github repository, the latest Provisional weekly Case Reports (bullet) data can be acquired, which may not be available on CRAN. To install the package, run the following command in your R console:

From CRAN:

install.packages("jpinfect")

From GitHub (for the latest version):

if(!require("remotes")) install.packages("remotes")remotes::install_github("TomonoriHoshi/jpinfect")

Load the package after installation:

library(jpinfect)

Usage

Built-in Datasets

The following datasets are included in this package and sourced from the Japan Institute for Health Security (JIHS). These datasets are:

  • sex_prefecture: Confirmed weekly case reports on the sex distribution of reported cases by prefecture from 1999 to 2023. For further details, run?sex_prefecture.

  • place_prefecture: Confirmed weekly case reports about the place of infection by prefecture between 2001 and 2023. For further details, run?place_prefecture.

  • bullet: Provisional weekly case reported by prefecture from 2024 to the current latest reports. For further details, run?bullet.

# Loading build-in datasetsdata("sex_prefecture")data("place_prefecture")data("bullet")

Data Merging

Thejpinfect_merge function helps to merge the datasets into one dataset if necessary, which enables users to start their data analysis instantly.

## Merge build-in datasets# Merging confirmed case reports into one datasetconfirmed_dataset<- jpinfect_merge(sex_prefecture,place_prefecture)# Merge three datasetsbind_result<- jpinfect_merge(sex_prefecture,place_prefecture,bullet)

Data Transformation from Wider to Longer; Vice Versa

Thejpinfect_pivot function enables users to seamlessly pivot datasets between wide and long formats. This functionality is particularly useful for reorganising data to suit analysis or visualisation needs.

# Pivot the dataset: wider to longerbullet_long<- jpinfect_pivot(bullet)# Pivot the dataset: longer to widerbullet_wide<-  jpinfect_pivot(bullet_long)

Thejpinfect_pivot function efficiently handles data transformation, ensuring compatibility with epidemiological workflows and making it easier to manage complex datasets.

Building Datasets from Source

Although the build-in datasets are provided in this package, it is ideal for scientists, epidemiologists and public health officers to review whole data handling process from the upstream to downstream. For those who cares the precision of dataset,jpinfect provides the following functions to build the same datasets or even the latest bullet datasets sourced from the government-provided raw data.

Data Source Checks

The sources of these datasets can be checked by usingjpinfect_url_confirmed for confirmed case reports andjpinfect_url_bullet for provisional case reports, respectively.

## Check the source URL for confirmed dataset# Download case reports by sex and prefecturejpinfect_url_confirmed(year=2021,type="sex")# Download case reports by the place of incetion and prefecturejpinfect_url_confirmed(year=2021,type="place")

Data Acquisition

The raw data can be downloaded usingjpinfect_get_confirmed for confirmed case reports andjpinfect_get_bullet for provisional case reports, respectively. Confirmed weekly case data is organised into a single Microsoft Excel file for each year, while provisional data is provided as separate CSV files for each week. Since this function connect to the government website, it may take some time to download the data. To avoid excessive burden on the server, please kindly avoid downloading the files frequently.

The downloaded files are saved under the specified directory (e.g.,raw_data folder). Throughout this example, thisraw_data directory is consistently used to store the raw data files.

Please ensure that the destination directory exists prior to execution, as the function does not create directories automatically. This behaviour complies with CRAN policy, which prohibits packages from creating directories within the user's environment.

If no destination is specified, the datasets will be stored in a temporary folder. Please note that this folder is session-specific and will be deleted once the R session is closed.

# Download data for 2020 and 2021jpinfect_get_confirmed(years= c(2020,2021),type="sex",dest_dir="raw_data")# Download data for all available yearsjpinfect_get_confirmed(type="place",dest_dir="raw_data")# Download English data for weeks 1 to 5 in 2025jpinfect_get_bullet(year=2025,week=1:5,dest_dir="raw_data")# Download Japanese data for all weeks in 2025jpinfect_get_bullet(year=2025,language="jp",dest_dir="raw_data")

Note: If the download fails on your local machine, it may succeed inPosit Cloud.

Data Import

The acquired raw data into your local computer could be imported into R usingjpinfect_read_confirmed andjpinfect_read_bullet.

⚠️Note: The import process may require several minutes to complete, particularly when processing large directories. This example may take a substantial amount of time depending on your internet connection and computer performance.

## Import confirmed case reports from file or directory# Process a single file with pathdataset2021<- jpinfect_read_confirmed(path="raw_data/2021_Syu_01_1.xlsx")# Process all files in a directoryplace_dataset<- jpinfect_read_confirmed(path="raw_data",type="place")## Import bullet case reports# Import all English reports in a local directorybullet_local<- jpinfect_read_bullet(directory="raw_data")# Import specific period of the data for 2025, weeks 1 to 10bullet2025<- jpinfect_read_bullet(year=2025,week=1:10,directory="raw_data")

Example Usage

The following example demonstrates how to use thejpinfect package to visualise the latest provisional weekly case reports in Japan. Specifically, it plots the provisional weekly number ofEnterohemorrhagic Escherichia coli infections.

with(    subset(bullet,prefecture=="Total"),    barplot(`Enterohemorrhagic Escherichia coli infection (weekly)`,# Selected column name in bullet datasetnames.arg=date,space=0,xlab= c("\n","Week"),# Add line breaks to move the x-axis label downylab="Provisional weekly cases",main="Recent Weekly Enterohemorrhagic Escherichia Coli infection in Japan",las=2,cex.names=0.6        ))

Example plot

Note: The example plot reflects a snapshot of the dataset at the time of writing. Due to periodic updates to built-in data, your results may vary slightly.

Community guidelines

If you encounter a bug or issue while using thejpinfect package, we encourage you to report ithere. If you are happy to contribute the package, please see ourcontributing guidelines.

We expect all contributors to adhere to theCode of Conduct to ensure a welcoming and inclusive environment for everyone.

About

R Package for Acquiring and Processing Data from Japan Institute for Health Security

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp