write.flist: Write a formatting list to the file system

View source: R/flist.R

write.flistR Documentation

Write a formatting list to the file system

Description

The write.flist function writes a formatting list to the file system. By default, the formatting list will be written to the current working directory, using the variable name as the file name. These defaults can be overridden using the appropriate parameters. The catalog will be saved with a file extension of ".flist".

Usage

write.flist(x, dir_path = getwd(), file_name = NULL)

Arguments

x

The formatting list to write.

dir_path

The directory path to write the catalog to. Default is the current working directory.

file_name

The name of the file to save the catalog as. Default is the name of the variable that contains the formatting list. The ".flist" file extension will be added automatically.

Value

The full path of the saved formatting list.

See Also

Other flist: as.data.frame.fmt_lst(), as.flist(), as.flist.data.frame(), as.flist.fcat(), as.flist.list(), as.flist.tbl_df(), flist(), is.flist(), print.fmt_lst(), read.flist()

Examples

# Create formatting list
fl <- flist(f1 = "%5.1f",
            f2 = "%6.2f",
            type = "row")
           
# Get temp directory
tmp <- tempdir()            
           
# Save formatting list to file system
pth <- write.flist(fl, dir_path = tmp)

# Read from file system
fr <- read.flist(pth)

# Create sample data
dat <- c(12.3844, 292.28432)

# Use formats in the catalog
fapply(dat, fr)
# [1] " 12.4"  "292.28"


dbosak01/fmtr documentation built on June 15, 2024, 4:26 a.m.