xlr_vector | R Documentation |
xlr_vector
vectorA general container for including additional styling options within a vector
so that it can easily be exported to Excel
. This vector type should be used
for characters, factors, Booleans, complex numbers, etc. It does
not support dates.
xlr_vector(x = vector(), excel_format = "GENERAL", style = xlr_format())
is_xlr_vector(x)
as_xlr_vector(x, excel_format = "GENERAL", style = xlr_format())
x |
A vector
|
excel_format |
a character, the |
style |
Additional styling options for the vector. See xlr_format for more details. |
While you can use it with integer
, and double
types and specifying the
associated Excel
format, we recommend using xlr_integer, xlr_numeric,
or xlr_percent types instead.
You can convert a vector back to its base type with as_base_r()
.
An S3 vector of class xlr_vector
xlr_percent()
, xlr_integer()
, xlr_numeric()
, as_base_r()
library(xlr)
# Create a xlr_vector object, this is used so we can add styling to an existing
# vector so that it prints nicely in `Excel`
#
# Note currently the style will not change the style in the console
x <- xlr_vector(1:100,
excel_format = "00.0##",
style = xlr_format(font_size = 8))
# You can also use it so that dates are nicely printed in `Excel`
dates <- c("02/27/92", "02/27/92", "01/14/92", "02/28/92", "02/01/92")
dates <- as.Date(dates, "%m/%d/%y")
x <- xlr_vector(dates,
# Print it as a long date in `Excel`
excel_format = "LONGDATE")
# You can convert existing data to a xlr_vectors using dplyr verbs
iris |>
dplyr::mutate(iris_format = as_xlr_vector(Species,
"TEXT",
xlr_format(text_style = "italic")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.