read.fcat: Read a format catalog from the file system

Description Usage Arguments Value See Also Examples

View source: R/fcat.R

Description

The read.fcat function reads a format catalog from the file system. The function accepts a path to the format catalog, reads the catalog, and returns it.

Note that the format catalog is saved as an RDS file. The ".fcat" file extension only serves to distinguish the format catalog from other RDS files.

Usage

1
read.fcat(file_path)

Arguments

file_path

The path to the format catalog.

Value

The format catalog as an R object.

See Also

Other fcat: as.data.frame.fcat(), as.fcat.data.frame(), as.fcat.fmt_lst(), as.fcat.list(), as.fcat(), fcat(), is.fcat(), print.fcat(), write.fcat()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# 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)
fapply(c("A", "B", "C", "B"), c1$label_fmt)
fapply(Sys.Date(), c1$date_fmt)

fmtr documentation built on July 25, 2021, 9:06 a.m.