View source: R/jpinfect_read_bullet.R
jpinfect_read_bullet | R Documentation |
This function imports and processes surveillance data files downloaded from the Japan Institute for Health Security (JIHS). The processed data for the specified year and weeks is combined into a single data frame, optionally saved to a file.
jpinfect_read_bullet(
year = NULL,
week = 1:53,
directory,
language = "en",
output_file = NULL
)
year |
An integer specifying the year of the data files to process. If NULL, all years available in the directory are processed. |
week |
A numeric vector specifying the weeks to process (default is 1:53). |
directory |
A string specifying the directory containing the JIHS data files (required). |
language |
A character string specifying the language of the data ('en' for English, 'jp' for Japanese). Default is 'en'. |
output_file |
A string specifying the file name to save the combined data. If NULL, the combined data is not saved (default is NULL). |
- The function reads all files matching the specified 'year' and 'language' in the given 'directory'. - Files are filtered based on their naming patterns, which include '_zensu_en.csv' for English and '_zensu_jp.csv' for Japanese. - Each file is read and processed, including renaming columns, adding 'year' and 'week' information, and rearranging columns. - If no files matching the criteria are found, the function raises an error. - Processed data for all specified files is combined into a single data frame.
A data frame containing the combined and processed JIHS surveillance data. If 'output_file' is specified, the data is also saved to a CSV file in the specified directory.
# Process data for 2025, weeks 1 to 10, in English, and save the output
combined_data <- jpinfect_read_bullet(year = 2025, week = 1:10,
directory = "raw_data", language = "en",
output_file = "processed_2025.csv")
# Process Japanese data for all available years in the directory
combined_data <- jpinfect_read_bullet(directory = "raw_data", language = "jp")
# Process data for 2023, weeks 5 to 15, without saving the output
combined_data <- jpinfect_read_bullet(year = 2023, week = 5:15,
directory = "raw_data", language = "en")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.