Coerce a character or named vector to a page data.frame using get_page_size() or make_page_size()
Source:R/as_page.R
as_page.RdCoerce a character or named vector to a page data.frame using get_page_size() or make_page_size()
Usage
as_page(x, ..., cols = c("width", "height"), class = "data.frame")Arguments
- x
A character vector passed to the name parameter of
get_page_size(), a named list of vector passed to dims formake_page_size(), or a length 2 numeric vector passed as the width and height parameter tomake_page_size(). If x is a character string that does not match any of the names in paper_sizes, x is passed as the name parameter tomake_page_size()- ...
Arguments passed on to
make_page_sizewidth,heightPage width and height. Both are required, if asp is
NULL. Default toNULL.unitsUnits for width and height. Required unless units is included in dims. Passed to
as_unit_type()to validate.aspAspect ratio. Required if only one of width or height are provided.
nameOptional name for paper size. Recommend avoiding duplication with existing names in
paper_sizes.dimsA list or data.frame that can be used to set width, height, units, and/or asp.
orientationPage orientation, Default:
NULL. Supported options are "portrait", "landscape", or "square". If width and height suggest a portrait orientation when orientation = "landscape", the dimensions are reversed so the page dimensions match the provided orientation.valid_unitsCharacter vector with name or symbols for valid units. Defaults to
NULLbut any other unit name or symbol, e.g. "px", is permitted.callThe execution environment of a currently running function, e.g.
call = caller_env(). The corresponding function call is retrieved and mentioned in error messages as the source of the error.You only need to supply
callwhen throwing a condition from a helper function which wouldn't be relevant to mention in the message.Can also be
NULLor a defused function call to respectively not display any call or hard-code a code to display.For more information about error calls, see Including function calls in error messages.
- cols
Column names to use for width and height columns. Defaults to c("width", "height"). Must be length 2 and the first value is always used as as the width name and the second as the height.
- class
Class of return object: "data.frame" (default) or "list" (only supported when input page size is a single row).
Examples
as_page(c(8.5, 11), units = "in")
#> width height units orientation asp
#> 1 8.5 11 inches portrait 0.7727273
as_page("letter")
#> # A tibble: 1 × 10
#> name series size standard units width height orientation type asp
#> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <chr> <chr> <dbl>
#> 1 Letter NA NA ANSI in 8.5 11 portrait paper 0.773
as_page(
list(name = "letter", w = 8.5, h = 11, units = "in"),
cols = c("w", "h")
)
#> w h units orientation asp
#> 1 8.5 11 inches portrait 0.7727273