| write_factor | R Documentation |
Write a factor in the CLS format
write_factor(fac, con = stdout(), offset = 0, sep = c("\t", " "))
write_cls(fac, con = stdout(), offset = 0, sep = c("\t", " "))
fac |
A factor |
con |
Connection to write to |
offset |
he integer representing the first level, default is set to 0, for some software it can be set to 1 |
sep |
Separator used in the CLS format, can be '\t' (recommended) or ' ' (not to be used when space exists in levels) |
No return value, called for side effects (writes to connection).
The original CLS format specifies that both tab or space can be used as separators.
This makes it unable to represent factors with sapces in levels. In order to accomodate
CLS format for these factors, we propose using tab as separators in CLS files when encoding factors
in R. The default setting of read_factor and write_factor uses tab.
read_factor
set.seed(1887)
tempfac <- factor(sample(LETTERS, 30, replace=TRUE), levels=sample(LETTERS))
tempfile <- tempfile()
write_factor(tempfac, tempfile)
readLines(tempfile)
stopifnot(identical(tempfac, read_factor(tempfile)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.