write_fwf: Generate fixed width file in R

View source: R/write-fwf.r

write_fwfR Documentation

Generate fixed width file in R

Description

https://gist.github.com/haozhu233/28d1309b58431f4929f78243054f1f58

Usage

write_fwf(dt, width, con = stdout(), align = "l", na = "NA", col.names = TRUE)

Arguments

dt

The data to be printed

width

Either a single number or a vector of widths

con

Connection, as in writeLines(); default is stdout().

align

"l", "r" or something like "lrl" for left, right, left.

na

What to print in places of missing values; default: "NA"

col.names

Print column names? Default: TRUE

Examples

dt <- data.frame(a = 1:3, b = NA, c = c('a', 'b', 'c'))
write_fwf(dt, width = c(4, 4, 3))
write_fwf(dt, 5)

X <- matrix(LETTERS[1:9], 3, 3, dimnames=list(1:3, paste0('V', 1:3)))
write_fwf(X, 6)

pbreheny/breheny documentation built on Sept. 5, 2024, 6:45 p.m.