Helper function to append and validate psItemContent
class.
See vignette for details.
psItemContent( items, dir_bin = NULL, lang = NULL, fontsize_global = NULL, alignment = "left", linestretch = 2, paperwidth = 8.5, paperheight = 5.4, top = 0.5, bottom = 0.5, left = 0.5, right = 0.5, unit = "cm", vcentering = TRUE, hcentering = TRUE ) # S3 method for psItemContent validate_S3(x, ps_coll = NULL, ...) as_psItemContent(obj, ...) # S3 method for character as_psItemContent(obj, ...) # S3 method for psSort as_psItemContent(obj, ...) # S3 method for psItemContent print(x, ...) # S3 method for psItemContentText knit_print(x, inline = FALSE, ...) # S3 method for psItemContentText export_ps(x, dir = ".", overwrite = FALSE, format = "pdf") # S3 method for psItemContentText plot(x)
items |
|
---|---|
dir_bin |
|
lang |
Must be one of:
Used for multilingual typsetting support via LaTeX's babel package and others. Careful: Depending on the local tex distribution, not all valid languages may also be supported by LaTeX. Use |
fontsize_global |
Must be one of:
|
alignment |
Must be one of:
|
linestretch |
|
paperwidth |
|
paperheight |
|
top |
|
bottom |
|
left |
|
right |
|
unit |
Must be one of:
|
vcentering |
|
hcentering |
|
x | An object with one of the pensieve S3 classes. |
ps_coll |
|
... | further arguments to be passed to methods. |
obj | An object which can be coerced to psItemContent, currently one of:
|
inline |
|
dir |
|
overwrite |
|
format |
Must be one of:
|
[character()]
with class psItemContent
.
Store full items along with metadata (language, design) to enable deployment and convenience functions, as well as enhance the presentation of results.
validate_S3
: Validation
as_psItemContent
: Coerce from character vector
as_psItemContent
: Coerce from psSort
print
: Printing to the console
knit_print
: Printing inside knitr chunks
export_ps
: Export rendered text items to vector formats.
plot
: Plot rendered item. Defaults to first item.
Extends the knitr::knit_print()
generic for pensieve S3 objects.
By default print()
in knitr will default to knitr::knit_print()
, so to nicely print some object obj
inside a chunk, you can just write print(obj)
or even just obj
.
However, to manually invoke or preview the interactive displays in RStudio, you must call knitr::knit_print()
in full.
The base::print()
ing method of the underlying classes is not altered outside of a knitr chunk.
Plotting items to the R graphics system has some limitations:
You can only plot one item at a time. The function defaults to the first item.
The item is placed in the aspect ratio given by psItemContent()
in the middle of the plotting area.
There may be additional white space around the item.
This is because R graphics must offer arbitrary aspect ratios, but items have a fixed aspect ratio.
For good-looking results, you should set the aspect ratio of the plotting area to equal that of the items.
Other S3 classes from pensieve
:
correlate()
,
extract()
,
psClosedSorts()
,
psGrid()
,
psOpenSorts()
,
psOpenSort()
,
psPeople()
,
score()
Other print functions:
psGrid()
# text items with handles items_text_en <- psItemContent( items = c( "live_2_work" = "Man lives to work.", "work_2_live" = "Man works to live." ), lang = "en-US" ) # text items without handles items_text_de <- psItemContent( items = c( "Man lebt um zu arbeiten.", "Man arbeitet, um zu leben." ), lang = "de-DE" ) # text items without multilingual typographic support items_text_esperanto <- psItemContent( items = c( "Viro vivas por labori.", "Viro laboras vivi." ) ) # image items # these images ship with pensieve # location depends on runtime; ignore next three lines dir_bin <- file.path("..", "..", "inst", "extdata", "fruit") if (!dir.exists(dir_bin)) { dir_bin <- file.path(system.file(package = "pensieve"), "extdata", "fruit") } items_image <- psItemContent( items = c("peach.jpg", "pear.jpg"), dir_bin = dir_bin )