write_fwf_blaise {blaise} | R Documentation |
Write a fixed width ascii datafile and accompanying blaise datamodel
Description
Write a datafile in the blaise format (fwf ascii without separators) will always write out a blaise datamodel describing the datafile as well
Usage
write_fwf_blaise(
df,
output_data,
output_model = NULL,
decimal.mark = ".",
digits = getOption("digits"),
justify = "right",
write_model = TRUE,
model_name = NULL
)
Arguments
df |
dataframe to write |
output_data |
path and name to output datafile. Will add .asc if no extension |
output_model |
path and name to output datamodel. If NULL will use the same name as output_data with .bla extension. |
decimal.mark |
decimal mark to use. Default is ".". |
digits |
how many significant digits are to be used for numeric and complex x. The default uses getOption("digits"). This is a suggestion: enough decimal places will be used so that the smallest (in magnitude) number has this many significant digits. |
justify |
direction of padding for STRING type when data is smaller than the width. Defaults to right-justified (padded on the left), can be "left", "right" or "centre". |
write_model |
logical that can be used to disable the automatic writing of a datamodel |
model_name |
Custom name that can be given to the datamodel. Default is the name of the dataframe |
Details
Currently supports the following dataformats:
character => STRING,
integer => INTEGER,
numeric => REAL,
Date => DATETYPE,
factor => ENUM (will convert factor with numbers as labels to STRING)
logical => INTEGER
Value
output as it is written to file as a character vector. Does so invisibly, will not print but can be assigned.
Examples
datafilename = tempfile('testdata', fileext = '.asc')
blafilename = tempfile('testbla', fileext = '.bla')
data = data.frame(1, 1:10, sample(LETTERS[1:3], 10, replace = TRUE), runif(10, 1, 10))
write_fwf_blaise(data, datafilename)
unlink(c(datafilename, blafilename))