- Notifications
You must be signed in to change notification settings - Fork0
R Package for Acquiring and Processing Data from Japan Institute for Health Security
License
TomonoriHoshi/jpinfect
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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.
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)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")
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)
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.
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.
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")
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.
The acquired raw data into your local computer could be imported into R usingjpinfect_read_confirmed andjpinfect_read_bullet.
## 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")
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 ))
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.
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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
