# Create format catalog
c1 <- fcat(num_fmt = "%.1f",
label_fmt = value(condition(x == "A", "Label A"),
condition(x == "B", "Label B"),
condition(TRUE, "Other")),
date_fmt = "%d%b%Y")
# Get temp directory
tmp <- tempdir()
# Save catalog to file system
pth <- write.fcat(c1, dir_path = tmp)
# Read from file system
c2 <- read.fcat(pth)
# Use formats in the catalog
fapply(2, c1$num_fmt)
# [1] "2.0"
fapply(c("A", "B", "C", "B"), c1$label_fmt)
# [1] "Label A" "Label B" "Other" "Label B"
fapply(Sys.Date(), c1$date_fmt)
# [1] "07Jan2024"
Run the code above in your browser using DataLab