View source: R/jpinfect_pivot.R
jpinfect_pivot | R Documentation |
This function pivots a dataset between long and wide formats based on the column count. If the dataset has 5 or fewer columns, it is pivoted to a wide format, keeping 'prefecture', 'year', 'week' and 'date' as fixed identifiers. If the dataset has more than 5 columns, it is pivoted to a long format.
jpinfect_pivot(dataset)
dataset |
A data frame containing the columns 'prefecture', 'year', 'week', 'date' and additional columns for diseases and their associated case counts. |
- If the dataset has 5 or fewer columns, the function uses 'pivot_wider()' to convert the dataset to a wide format. - If the dataset has more than 5 columns, the function uses 'pivot_longer()' to convert the dataset to a long format. - The function ensures that the columns 'prefecture', 'year', 'week' and 'date' are always present.
A data frame that is pivoted either to a long or wide format, depending on the number of columns. If 'prefecture', 'year', 'week' or 'date' are missing from the dataset, the function stops with an error.
# Pivot the dataset
result <- jpinfect_pivot(place_prefecture)
print(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.