The goal of mvcommon is to provide shared utilities, validation functions, and common infrastructure for the macroverse ecosystem. This lightweight package ensures consistency across all macroverse packages without introducing heavy dependencies.
This package is part of the macroverse ecosystem.
You can install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("macroverse-r/mvcommon")library(mvcommon)
# Validate and fix common data issues
data <- mv_validate_data(my_data)
# Validate date formats
dates <- mv_validate_date_format(c("2020", "2020Q1"), format = "auto")
# Convert and validate in one step
clean_data <- mv_as_valid_data(messy_data)# Consistent error messages across packages
mv_stop("Invalid input",
"x" = "Expected numeric vector",
"i" = "Got character vector instead")
# Progress bars for long operations
pb <- mv_progress_bar(100,
format = "Processing {cli::pb_current}/{cli::pb_total} items")
for (i in 1:100) {
# Do work...
pb$tick()
}# Set global options for the ecosystem
mv_set_config(verbose = TRUE,
debug = FALSE,
encoding = "UTF-8")
# Check current settings
mv_get_config("verbose")
#> [1] TRUE# Standardize country names for ISO matching
names <- c("USA", "U.S.A.", "United States", "Côte d'Ivoire")
mv_standardize_country_name(names)
#> [1] "USA" "USA" "USA" "Ivory Coast"# Add metadata to track data provenance
data <- mv_add_metadata(data,
source = "World Bank",
download_date = Sys.Date(),
indicators = c("GDP", "Population"))
# Retrieve metadata later
mv_get_metadata(data)# Check memory usage before operations
mv_memory_usage(large_dataset, operation = "join", another_dataset)
# Check internet connectivity
if (mv_check_internet()) {
# Download data...
}# Get colorblind-friendly palettes
colors <- mv_get_colors("default")
plot(1:8, col = colors, pch = 19, cex = 3)
# Get all available palettes
all_palettes <- mv_get_colors("all")The mvcommon package is the foundation of the macroverse ecosystem: - mvcommon: Common utilities (this package) - pplot: Panel data visualization - isomapper: ISO codes and country mapping - macrodata: Data loading and processing - mvlazy: Convenience functions - macroverse: Meta-package loading all components
This package is licensed under AGPL-3.0.