Title: | The Schola Empirica Package |
---|---|
Description: | A collection of utilies, themes and templates for data analysis at Schola Empirica. |
Authors: | Petr Bouchal [aut] , Jan Netík [aut, cre] , Jaromír Mazák [ctb], Aleš Vomáčka [ctb], SCHOLA EMPIRICA, z. s. [cph, fnd] |
Maintainer: | Jan Netík <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.5.6.9000 |
Built: | 2024-11-09 06:09:34 UTC |
Source: | https://github.com/scholaempirica/reschola |
czech_date
Appends the czech_date
class attribute to the input object. Date of class
czech_date
is printed as a date in long format with correct Czech
grammatical case (see Details and Grammatical cases section below).
as_czech_date(date, case = "genitive")
as_czech_date(date, case = "genitive")
date |
date or date-like object to parse. |
case |
character, either "nominative", "locative" or "genitive" (default) or any unambiguous abbreviation of these. |
The grammatical case should be specified as and argument to print()
method, but for convenience, you can predefine it in as_czech_date
call
directly. It is then stored as an attribute, later grabbed by the print
method.
Note that as opposed to other date formating functions in R
,
as_date_czech
trims leading zeros.
Same as input, but with class czech_date
and attribute
gramm_case
.
Three grammatical cases are supported:
nominative – native form, i.e. "leden" in Czech
locative – "in ...", i.e. "v lednu" in Czech
genitive – "the 'nth' of ...", i.e. "5. ledna" in Czech
Czech months listed by case are available in .czech_months
.
Sys.time() %>% as_czech_date() # in "nominative" grammatical case (note the abbreviation) Sys.time() %>% as_czech_date("nom")
Sys.time() %>% as_czech_date() # in "nominative" grammatical case (note the abbreviation) Sys.time() %>% as_czech_date("nom")
Saves everything opened in a current project, renders (compiles) chosen
.Rmd
document(s), and opens the resulting file if everything went OK.
compile_and_open( input, output_dir = "reports-output", open_on_success = TRUE, ... )
compile_and_open( input, output_dir = "reports-output", open_on_success = TRUE, ... )
input |
path to source |
output_dir |
output directory, default to "reports-output" |
open_on_success |
if compilation went successul, open the result, default to TRUE |
... |
Arguments passed on to
|
No return value. Called for side effects.
## Not run: # for which REDIZOs should the reports be compiled? red_izos <- c("600000001", "600000002", "600000003") purrr::map( red_izos, ~ compile_and_open("05_ucitele-reditele_ms.Rmd", open_on_success = FALSE, output_dir = here("reports-output", "ucitele-reditele-ms"), output_file = paste0("02_ucitele-reditele-ms_", .x, ".docx"), params = list(redizo = .x) ) ) ## End(Not run)
## Not run: # for which REDIZOs should the reports be compiled? red_izos <- c("600000001", "600000002", "600000003") purrr::map( red_izos, ~ compile_and_open("05_ucitele-reditele_ms.Rmd", open_on_success = FALSE, output_dir = here("reports-output", "ucitele-reditele-ms"), output_file = paste0("02_ucitele-reditele-ms_", .x, ".docx"), params = list(redizo = .x) ) ) ## End(Not run)
Copy default Schola template into project directory
copy_schola_template(format = "pdf", path = proj_get(), ...)
copy_schola_template(format = "pdf", path = proj_get(), ...)
format |
Character, format which to look for. Defaults to |
path |
Character, path to copy to. Defaults to the current project root. |
... |
Arguments passed on to
|
No return value, called for side effect.
Jan Netik
Other Report templates and formats:
open_schola_template()
,
schola_pdf()
,
schola_word()
,
schola_word2()
## Not run: copy_schola_template() ## End(Not run)
## Not run: copy_schola_template() ## End(Not run)
Returns the most space-efficient and at the same time grammatically correct
interval of two Czech dates. When both dates are the same, only one is
outputted. The function ensures that the interval is not negative (i.e.,
start
<= end
), otherwise, it is reversed.
czech_date_interval(start, end)
czech_date_interval(start, end)
start |
Date of date-like object, start date or left boundary of an interval. |
end |
Date of date-like object, end date or right boundary of an interval. |
Character
czech_date_interval("2020-01-24", "2020-01-03") # note the argument order
czech_date_interval("2020-01-24", "2020-01-03") # note the argument order
Item labels have to be stored as variable attribute label
. Exported by
default by ls_export()
, but many data wrangling operations strip them out,
unfortunately.
dict_from_data(.data)
dict_from_data(.data)
.data |
data.frame or tibble |
named character vector of items' labels, if no label found, NULL is introduced and is omitted in the output
.Rmd
draft using Schola templatesShortcut function to create a new .Rmd
file using Schola standard templates
and open it for editing.
draft_pdf(name = "pdf_draft", open = TRUE) draft_word(name = "word_draft", open = TRUE)
draft_pdf(name = "pdf_draft", open = TRUE) draft_word(name = "word_draft", open = TRUE)
name |
character, name to use for new file. With or without file extension. |
open |
logical, whether to open file for editing, defaults to TRUE. |
Path to the created file (invisibly).
Other Workflow helpers:
gd_download_folder()
,
manage_docx_header_logos()
## Not run: draft_pdf("best_report") ## End(Not run)
## Not run: draft_pdf("best_report") ## End(Not run)
Note that item labels are automatically derived using the labeller from given schola_barplot
result
extract_schola_barplot_info(plot)
extract_schola_barplot_info(plot)
plot |
result of schola_barplot() call |
tibble with plot data
"TODO"
"TODO"
The inverse of fct_explicit_na()
. Turns the level
into proper NA
.
Retains the level.
fct_nanify(f, level, negate = FALSE, ignore_case = TRUE)
fct_nanify(f, level, negate = FALSE, ignore_case = TRUE)
f |
factor to work on |
level |
character, regular expression matching the desired level |
negate |
logical, whether to return non-matching elements. Defaults to
|
ignore_case |
logical, ignore case when matching? Defaults to |
factor with NA-substituted level.
f <- factor(c("a", "b", "c", "nanify")) fct_nanify(f, "nanify")
f <- factor(c("a", "b", "c", "nanify")) fct_nanify(f, "nanify")
A shorcut for making axis text flush with axis
flush_axis
flush_axis
An object of class numeric
of length 4.
Other Making charts:
plot_lollipop()
,
prepare_lollipop_data()
,
schola_barplot()
,
theme_schola()
library(ggplot2) ggplot(mpg) + geom_bar(aes(y = class)) + scale_x_continuous(expand = flush_axis)
library(ggplot2) ggplot(mpg) + geom_bar(aes(y = class)) + scale_x_continuous(expand = flush_axis)
label_percent_cz()
returns a formatter that outputs percent labels with a " %" suffix and a decimal comma.
label_number_cz()
uses space as thousand separator and decimal comma.
Use these when you need to format labels on something other than X and Y axes
label_percent_cz( accuracy = NULL, scale = 100, prefix = "", suffix = " %", big.mark = " ", decimal.mark = ",", trim = TRUE, ... ) label_number_cz( accuracy = NULL, scale = 1, prefix = "", suffix = "", big.mark = " ", decimal.mark = ",", trim = TRUE, ... )
label_percent_cz( accuracy = NULL, scale = 100, prefix = "", suffix = " %", big.mark = " ", decimal.mark = ",", trim = TRUE, ... ) label_number_cz( accuracy = NULL, scale = 1, prefix = "", suffix = "", big.mark = " ", decimal.mark = ",", trim = TRUE, ... )
accuracy |
A number to round to. Use (e.g.) Applied to rescaled data. |
scale |
A scaling factor: |
prefix |
Additional text to display before the number. The suffix is
applied to absolute value before |
suffix |
Additional text to display after the number. |
big.mark |
Character used between every 3 digits to separate thousands. |
decimal.mark |
The character to be used to indicate the numeric decimal point. |
trim |
Logical, if |
... |
Other arguments passed on to |
library(reschola) library(ggplot2) ggplot(mpg, aes(hwy, cty)) + geom_point(aes(colour = cty / max(cty), size = hwy * 100)) + theme_schola(family = "sans", title_family = "sans", gridlines = "scatter") + scale_color_binned(labels = label_percent_cz()) + scale_size_binned(labels = label_number_cz())
library(reschola) library(ggplot2) ggplot(mpg, aes(hwy, cty)) + geom_point(aes(colour = cty / max(cty), size = hwy * 100)) + theme_schola(family = "sans", title_family = "sans", gridlines = "scatter") + scale_color_binned(labels = label_percent_cz()) + scale_size_binned(labels = label_number_cz())
Downloads all downloadable files from given Google Drive folder
and saves them to specified local directory. Files will have the same names.
Use googledrive::drive_download()
for downloading individual files.
gd_download_folder( folder_url = gd_get_proj(), dest_dir = "data/input", files_from_subfolders = FALSE, overwrite = TRUE )
gd_download_folder( folder_url = gd_get_proj(), dest_dir = "data/input", files_from_subfolders = FALSE, overwrite = TRUE )
folder_url |
Folder URL. |
dest_dir |
Local URL in which to store files. |
files_from_subfolders |
Whether to download also files from subdirectories.
Defaults to |
overwrite |
Whether to overwrite if file of same name exists. |
vector of paths to downloaded files
As it would be very difficult to mirror the folder exactly,
if files_from_subfolders
is set to TRUE
, files from subfolders will be
saved in the same directory, not in the respective subdirectories.
Bear this in mind when naming files in GDrive subfolders so as to avoid naming conflicts.
Other Workflow helpers:
draft_pdf()
,
manage_docx_header_logos()
## Not run: gd_url <- "https://drive.google.com/drive/folders/1bCyR_VKAP_43NEujqisjN77hANnMKfHZ" gd_download_folder( folder_url = gd_url, files_from_subfolders = T, overwrite = T ) ## End(Not run)
## Not run: gd_url <- "https://drive.google.com/drive/folders/1bCyR_VKAP_43NEujqisjN77hANnMKfHZ" gd_download_folder( folder_url = gd_url, files_from_subfolders = T, overwrite = T ) ## End(Not run)
Gets a hidden object .gd_proj_url
(by default) created at project
"startup". See the details below for reschola projects created prior reschola
version 0.4.0.
gd_get_proj(url_object = ".gd_proj_url")
gd_get_proj(url_object = ".gd_proj_url")
url_object |
character, name of the object URL is stored in.
|
A character vector of class drive_id
.
Call usethis::edit_r_profile(scope = "project")
and write (note the dot
prefix):
.gd_proj_url <- "your_google_drive_url"
Note that you have to restart your R session to apply any changes. Note
also that the URL cannot contain any query (parts with a leading
question mark), i.e. ?usp=sharing
.
Upload a file to project's Google Drive
gd_upload_file(file, dir = gd_get_proj())
gd_upload_file(file, dir = gd_get_proj())
file |
character, path to the file. |
dir |
Directory at Google Drive, defaults to current reschola project
directory picked up by |
An object of class dribble
, a tibble with one row per file.
reschola
projectNote that file paths are handled with here()
already.
get_input_data(file) get_intermediate_data(file) get_processed_data(file) write_input_data(.data, file) write_intermediate_data(.data, file) write_processed_data(.data, file)
get_input_data(file) get_intermediate_data(file) get_processed_data(file) write_input_data(.data, file) write_intermediate_data(.data, file) write_processed_data(.data, file)
file |
character, file name to get or write to, |
.data |
data object to save as RDS. |
get_*
returns object(s) in the .rds
being read
write_*
returns a fs_path
path of .rds
file being created invisibly
Get labels of variables
get_labs_df(.data)
get_labs_df(.data)
.data |
tibble or data.frame |
tibble with variables and its labels (as list-column)
# make labels for iris dataset, labels will be colnames # with dot replaced for whitespace iris_with_labs <- as.data.frame(mapply(function(x, y) { attr(x, "label") <- y return(x) }, iris, gsub("\\.", " ", colnames(iris)), SIMPLIFY = FALSE)) get_labs_df(iris_with_labs)
# make labels for iris dataset, labels will be colnames # with dot replaced for whitespace iris_with_labs <- as.data.frame(mapply(function(x, y) { attr(x, "label") <- y return(x) }, iris, gsub("\\.", " ", colnames(iris)), SIMPLIFY = FALSE)) get_labs_df(iris_with_labs)
The function relies on {extrafont}
package that comes with briken dependencies at the moment. An experimental
register_reschola_fonts()
is proposed.
import_fonts()
import_fonts()
This is an analogue of hrbrthemes::import_roboto_condensed()
.
There is an option reschola.loadfonts
which – if set to TRUE
– will
call extrafont::loadfonts()
to register non-core fonts with R PDF &
PostScript devices. If you are running under Windows, the package calls the
same function to register non-core fonts with the Windows graphics device.
If you install the fonts just for the current user (via right-click and
Install), they will probably not be discoverable by the fontspec
LaTeX package that is used for PDF report typesetting!
Fonts are licensed under the Ubuntu Font License.
Other Font helpers and shortcuts:
install_reschola_fonts()
,
register_reschola_fonts()
,
use_reschola_fonts()
Just a simple wizard.
install_reschola_fonts()
install_reschola_fonts()
Side effects.
Other Font helpers and shortcuts:
import_fonts()
,
register_reschola_fonts()
,
use_reschola_fonts()
The function takes a tibble
(or any object that is internally represented
as a (named) list
by R
) of participant(s) data and adds them to the
LimeSurvey participant database of the selected survey.
ls_add_participants(survey_id, part_data, create_token = TRUE)
ls_add_participants(survey_id, part_data, create_token = TRUE)
survey_id |
integer, ID of the survey (as found with |
part_data |
tibble / data.frame / list, object with participant(s)
data, i.e., |
create_token |
logical, whether to create token outright. Defaults to
|
Generally, your part_data
object have to contain three variables:
firstname
, lastname
, and email
. That is something like a bare minimum,
but you may add any attribute recognized by LimeSurvey – even custom
attributes like attribute_1
or so. For the human-readable list of custom
attributes being held in the LimeSurvey participant database of the selected
survey, use ls_get_attrs()
. However, do not use the "semantic" form, as
ls_add_participants()
recognizes only raw, i.e. attribute_1
notation.
Called for a side effect, but returns the inserted data including additional new information like the token string.
Other LimeSurvey functions:
ls_call()
,
ls_export()
,
ls_get_attrs()
,
ls_invite()
,
ls_login()
,
ls_participants()
,
ls_responses()
,
ls_set_participant_properties()
,
ls_surveys()
## Not run: # create participant table part_data <- tibble( firstname = "John", lastname = "Doe", email = "[email protected]", language = "cs", attribute_1 = "Example School" ) # insert participant into the LimeSurvey database ls_add_participants(123456, part_data) # check if OK ls_participants(123456) ## End(Not run)
## Not run: # create participant table part_data <- tibble( firstname = "John", lastname = "Doe", email = "[email protected]", language = "cs", attribute_1 = "Example School" ) # insert participant into the LimeSurvey database ls_add_participants(123456, part_data) # check if OK ls_participants(123456) ## End(Not run)
General function used internally by every other ls_
fellow. Useful when you
want something special that is not (yet) implemented in reschola
.
ls_call(method, params = list())
ls_call(method, params = list())
method |
character, a method supported by LimeSurvey API. |
params |
list, arguments of the method. Need to be in order stated in
documentation. Note that |
The list of available LimeSurvey API calls briefly documents the functionality provided. You must strictly adhere to the arguments positions, as they are passed as an array.
A tibble, or raw object if server response cannot be reasonably coerced to a tibble.
Other LimeSurvey functions:
ls_add_participants()
,
ls_export()
,
ls_get_attrs()
,
ls_invite()
,
ls_login()
,
ls_participants()
,
ls_responses()
,
ls_set_participant_properties()
,
ls_surveys()
## Not run: ls_call("get_survey_properties", params = list(iSurveyID = 123456)) ## End(Not run)
## Not run: ls_call("get_survey_properties", params = list(iSurveyID = 123456)) ## End(Not run)
Checks for illegal LS attributes and raises an error when any found.
ls_check_attributes(attributes)
ls_check_attributes(attributes)
attributes |
vector of attributes |
Export Responses with Participants Attached
ls_export( survey_id, attributes = TRUE, clean_labels = TRUE, n_participants = 999, lang = "cs", part = "all", only_unused_tokens = FALSE, join_by = "token", standardize_dates = TRUE, ... )
ls_export( survey_id, attributes = TRUE, clean_labels = TRUE, n_participants = 999, lang = "cs", part = "all", only_unused_tokens = FALSE, join_by = "token", standardize_dates = TRUE, ... )
survey_id |
integer, ID of the survey (as found with |
attributes |
logical try to recover all attributes (default to TRUE), or character vector specifying requested attributes. |
clean_labels |
logical, whether to clean labels of subquestions from
repeating parts. Defaults to |
n_participants |
integer, the number of participants to list, defualt to 999. |
lang |
character, ISO 639 language code, default to |
part |
character, completion status, either |
only_unused_tokens |
logical, should only the unused tokens be listed? Default to FALSE. |
join_by |
character, the joining variable present in both responses
and participants tibbles. Default to |
standardize_dates |
logical, whether to standardize dates to |
... |
Arguments passed on to
|
A tibble.
Other LimeSurvey functions:
ls_add_participants()
,
ls_call()
,
ls_get_attrs()
,
ls_invite()
,
ls_login()
,
ls_participants()
,
ls_responses()
,
ls_set_participant_properties()
,
ls_surveys()
## Not run: ls_export(123456) ## End(Not run)
## Not run: ls_export(123456) ## End(Not run)
A survey can comprise one or more custom attributes useful for encoding
participant characteristics directly within participants table. However,
LimeSurvey refers to them as attribute_x
(where x
is the attribute
position) which is not useful at all. The function aims to resolve this issue
by returning so-called "semantic" form of attributes with human-readable
description.
ls_get_attrs(survey_id)
ls_get_attrs(survey_id)
survey_id |
integer, ID of the survey (as found, e.g., with
|
A character vector of "semantic" attributes with names denoting "raw" attributes used internally by LimeSurvey.
Other LimeSurvey functions:
ls_add_participants()
,
ls_call()
,
ls_export()
,
ls_invite()
,
ls_login()
,
ls_participants()
,
ls_responses()
,
ls_set_participant_properties()
,
ls_surveys()
## Not run: ls_get_attrs(123456) ## End(Not run)
## Not run: ls_get_attrs(123456) ## End(Not run)
Send an email with a link to a survey to the particular participant(s). Uses email template specified in the LimeSurvey web interface. Please read the section "On errors and messages from the API server" of this documentation page before use.
ls_invite(survey_id, tid, uninvited_only = TRUE)
ls_invite(survey_id, tid, uninvited_only = TRUE)
survey_id |
integer, ID of the survey (as found with |
tid |
integer(s), one ore more token IDs (not tokens!) from
participant database to invite. Use |
uninvited_only |
logical, if |
LimeSurvey allows you to send so-called invitation to a participant, meaning
he or she will get an email containing a link with his or her unique access
token. If you wish to send the invitation even if it has been already sent,
use uninvited_only = FALSE
.
Called for a side effect. Returns a message from the server.
Note that the function passes on any messages from the LimeSurvey API server. As usual with LimeSurvey, many things are erroneous, buggy or does not make sense. In this case, a sign of a successful invitation is something like "-1 left to send" (where "-1" denotes the number of invitations sent).
Another message you may see is "Error: No candidate tokens", which
possibly means that the tid
s you use are not present in the survey of
concern. However, it can also indicate that the invitation has been already
sent to the tid
s and you have to use uninvited_only = FALSE
to proceed.
Note that when you add an email entry that has not a proper email format,
no participants are added and tibble with errors$email
list-column is
returned.
Other LimeSurvey functions:
ls_add_participants()
,
ls_call()
,
ls_export()
,
ls_get_attrs()
,
ls_login()
,
ls_participants()
,
ls_responses()
,
ls_set_participant_properties()
,
ls_surveys()
## Not run: ls_invite(123456, 18) ## End(Not run)
## Not run: ls_invite(123456, 18) ## End(Not run)
Obtains XML-RPC/JSON-RPC session key and stores it in dedicated environment
for further use by fellow ls_
functions.
ls_login( api_url = "https://dotazniky.scholaempirica.org/limesurvey/index.php/admin/remotecontrol" )
ls_login( api_url = "https://dotazniky.scholaempirica.org/limesurvey/index.php/admin/remotecontrol" )
api_url |
character, URL of the API endpoint, default to SCHOLA EMPIRICA's LimeSurvey API. |
By default, https://dotazniky.scholaempirica.org/ is used as the LimeSurvey server prividing the API. The credentials used for user authentication are obtained through interactive prompts, mainly for security reasons. The function tries to obtain the credentials from the system environment variable table first. If none found, the user is asked for them and is provided with guidance for permanent credential storage.
No "explicit" return value, but assigns the session key to a dedicated environment.
Other LimeSurvey functions:
ls_add_participants()
,
ls_call()
,
ls_export()
,
ls_get_attrs()
,
ls_invite()
,
ls_participants()
,
ls_responses()
,
ls_set_participant_properties()
,
ls_surveys()
## Not run: ls_login() ## End(Not run)
## Not run: ls_login() ## End(Not run)
Fetches participant list of the solicited survey. The function tries to
retrieve as many attributes as possible and translate them to their
"semantic" version by default. You can also provide character vector of
requested attributes, but not in the "semantic" form (use, e.g.,
attribute_1
or usesleft
).
ls_participants( survey_id, attributes = TRUE, n_participants = 999, only_unused_tokens = FALSE, translate_attrs = TRUE, standardize_dates = TRUE )
ls_participants( survey_id, attributes = TRUE, n_participants = 999, only_unused_tokens = FALSE, translate_attrs = TRUE, standardize_dates = TRUE )
survey_id |
integer, ID of the survey (as found, e.g., with
|
attributes |
logical try to recover all attributes (default to TRUE), or character vector specifying requested attributes. |
n_participants |
integer, the number of participants to list, defualt to 999. |
only_unused_tokens |
logical, should only the unused tokens be listed? Default to FALSE. |
translate_attrs |
logical, should the custom attributes be "translated" to "semantic" version? Default to TRUE. |
standardize_dates |
logical, whether to standardize dates to |
A tibble, or raw object if server response cannot be reasonably coerced to a tibble.
Other LimeSurvey functions:
ls_add_participants()
,
ls_call()
,
ls_export()
,
ls_get_attrs()
,
ls_invite()
,
ls_login()
,
ls_responses()
,
ls_set_participant_properties()
,
ls_surveys()
## Not run: ls_participants(123456, attributes = c("usesleft")) ## End(Not run)
## Not run: ls_participants(123456, attributes = c("usesleft")) ## End(Not run)
Fetches responses and applies so-called "R-syntax" transformation script from
LimeSurvey pertaining factor levels and items labels (those are readily
available in RStudio data frame preview and can be extracted using
attr(.data, "label")
). By default, the function attempts to "clean" the
labels (clean_labels
argument), keeping only the content inside [...]
, if
there are any.
ls_responses( survey_id, clean_labels = TRUE, lang = "cs", part = "all", standardize_dates = TRUE, ... )
ls_responses( survey_id, clean_labels = TRUE, lang = "cs", part = "all", standardize_dates = TRUE, ... )
survey_id |
integer, ID of the survey (as found with |
clean_labels |
logical, whether to clean labels of subquestions from
repeating parts. Defaults to |
lang |
character, ISO 639 language code, default to |
part |
character, completion status, either |
standardize_dates |
logical, whether to standardize dates to |
... |
other named arguments used by "export_responses" method. Use at your own risk. |
A tibble, or raw object if server response cannot be reasonably coerced to a tibble.
Other LimeSurvey functions:
ls_add_participants()
,
ls_call()
,
ls_export()
,
ls_get_attrs()
,
ls_invite()
,
ls_login()
,
ls_participants()
,
ls_set_participant_properties()
,
ls_surveys()
## Not run: ls_responses(123456) ## End(Not run)
## Not run: ls_responses(123456) ## End(Not run)
Set or Edit Attribute(s) of an Participant
ls_set_participant_properties(survey_id, participant, ...)
ls_set_participant_properties(survey_id, participant, ...)
survey_id |
integer, ID of the survey (as found with |
participant |
integer or list, one token ID (not token!) from
participant database. Use |
... |
attributes in the form |
A tibble with the participant row just edited.
Other LimeSurvey functions:
ls_add_participants()
,
ls_call()
,
ls_export()
,
ls_get_attrs()
,
ls_invite()
,
ls_login()
,
ls_participants()
,
ls_responses()
,
ls_surveys()
## Not run: ls_set_participant_properties(123456, participant = 18, email = "[email protected]", attribute_1 = 600123456 ) ## End(Not run)
## Not run: ls_set_participant_properties(123456, participant = 18, email = "[email protected]", attribute_1 = 600123456 ) ## End(Not run)
Standardize Date Variables in LimeSurvey Data
ls_standardize_dates( .data, date_cols = c("completed", "sent", "submitdate", "startdate", "datestamp"), as_na = c("", "N", "Y"), ... )
ls_standardize_dates( .data, date_cols = c("completed", "sent", "submitdate", "startdate", "datestamp"), as_na = c("", "N", "Y"), ... )
.data |
tibble, data frame with LimeSurvey data. |
date_cols |
character, names of date columns to be standardized. |
as_na |
character, values to be coerced to |
... |
Arguments passed on to
|
A tibble with standardized date variables.
Lists every single survey found at the server you are logged in. Useful to gain information about the surveys IDs etc.
ls_surveys()
ls_surveys()
A tibble.
Other LimeSurvey functions:
ls_add_participants()
,
ls_call()
,
ls_export()
,
ls_get_attrs()
,
ls_invite()
,
ls_login()
,
ls_participants()
,
ls_responses()
,
ls_set_participant_properties()
## Not run: ls_surveys() ## End(Not run)
## Not run: ls_surveys() ## End(Not run)
Takes an existing Word document created using the reschola
templates
and adds (by default, or replaces if action = "replace_schola"
) the logo with
the image file you point it to.
manage_docx_header_logos( docx_path, png_logo_path, action = c("add_client", "replace_schola"), height = NULL )
manage_docx_header_logos( docx_path, png_logo_path, action = c("add_client", "replace_schola"), height = NULL )
docx_path |
The Word document in which to replace logos. Must contain the bookmarks
|
png_logo_path |
a PNG file which will be added/used as replacement |
action |
whether to add new logo on the right ( |
height |
height of the new logo in the resulting document, in |
invisibly returns the name of the new Word doc, which is same as the input Word doc,
with an an added _addedlogo
suffix.
This requires specific bookmarks in the header of the input document. This is taken from the skeleton.docx template in the template components. If you overwrite the header in the input document, this function will not work.
Other Workflow helpers:
draft_pdf()
,
gd_download_folder()
## Not run: library(reschola) manage_docx_header_logos("draft.docx", png_logo_path = "logos/newlogo.png", action = "add_client" ) manage_docx_header_logos("draft.docx", png_logo_path = "logos/newlogo.png", action = "replace_schola" ) ## End(Not run)
## Not run: library(reschola) manage_docx_header_logos("draft.docx", png_logo_path = "logos/newlogo.png", action = "add_client" ) manage_docx_header_logos("draft.docx", png_logo_path = "logos/newlogo.png", action = "replace_schola" ) ## End(Not run)
Open the default Schola templates used by schola_word()
, or
schola_pdf()
(specify with format
argument). The templates are shipped
with the package and are somewhat hidden in R
library, so this auxiliary
function can help you dig them up.
open_schola_template(format = "pdf")
open_schola_template(format = "pdf")
format |
Character, format which to look for. Defaults to |
You can either edit the chosen template directly in its natural habitat (questionable short-term solution), or better – use "Save as" option and keep it and use it within the project directory.
No return value, called for side effect.
Jan Netik
Other Report templates and formats:
copy_schola_template()
,
schola_pdf()
,
schola_word()
,
schola_word2()
## Not run: open_schola_template() ## End(Not run)
## Not run: open_schola_template() ## End(Not run)
plot_lollipop( plot_data, direction = "blue_larger", var_labels = waiver(), negative_label = NULL, positive_label = NULL, ref_label = NULL, xlab = "rozdíl mezi Vaší školou a ostatními", observations_alpha = 0.2 )
plot_lollipop( plot_data, direction = "blue_larger", var_labels = waiver(), negative_label = NULL, positive_label = NULL, ref_label = NULL, xlab = "rozdíl mezi Vaší školou a ostatními", observations_alpha = 0.2 )
plot_data |
a |
direction |
a |
var_labels |
a |
negative_label |
a |
positive_label |
a |
ref_label |
a |
xlab |
a |
observations_alpha |
opacity of individual observations |
ggplot2 plot
Other Making charts:
flush_axis
,
prepare_lollipop_data()
,
schola_barplot()
,
theme_schola()
plot_lollipop()
prepare_lollipop_data(.data, vars, group)
prepare_lollipop_data(.data, vars, group)
.data |
tibble or data.frame with variables |
vars |
variables to reshape from wide to long, uses tidyselect syntax |
group |
grouping variable (have to be logical!), usually denoting for which school the plot should be tailored for |
several tibbles inside list, intended for data-mining and for plotting
Other Making charts:
flush_axis
,
plot_lollipop()
,
schola_barplot()
,
theme_schola()
Many operations, such as rbind, cbind or its tidyverse analogues, strips
out the variable labels. Use recover_labs()
to bring them back from a
tibble
or data.frame
where they are last present. The function attempts a
few checks for new and original data compatibility. Note that the infix
operator is available for a quick and self-explanatory usage.
recover_labs(new_data, orig_data) new_data %labs_from% orig_data
recover_labs(new_data, orig_data) new_data %labs_from% orig_data
new_data |
new dataframe that you want to recover the labs for |
orig_data |
original dataframe with variable labels present |
Tibble or data.frame with variable labels restored.
# make labels for iris dataset, labels will be colnames # with dot replaced for whitespace iris_with_labs <- as.data.frame(mapply(function(x, y) { attr(x, "label") <- y return(x) }, iris, gsub("\\.", " ", colnames(iris)), SIMPLIFY = FALSE)) iris_with_recovered_labs <- recover_labs(iris, iris_with_labs) iris_with_recovered_labs_infix <- iris %labs_from% iris_with_labs # check get_labs_df(iris_with_recovered_labs) get_labs_df(iris_with_recovered_labs_infix)
# make labels for iris dataset, labels will be colnames # with dot replaced for whitespace iris_with_labs <- as.data.frame(mapply(function(x, y) { attr(x, "label") <- y return(x) }, iris, gsub("\\.", " ", colnames(iris)), SIMPLIFY = FALSE)) iris_with_recovered_labs <- recover_labs(iris, iris_with_labs) iris_with_recovered_labs_infix <- iris %labs_from% iris_with_labs # check get_labs_df(iris_with_recovered_labs) get_labs_df(iris_with_recovered_labs_infix)
The function is only for Windows, where it tries to register font family provided with "Windows bitmap device". On other platforms, fonts should be readily available after installation. Note that even on Windows, you can instruct RStudio to use smarter graphics device, such as "AGG" or "Cairo" (Tools > Global Options > General > Graphics > Backend).
register_reschola_fonts(family = c("Ubuntu", "Ubuntu Condensed"))
register_reschola_fonts(family = c("Ubuntu", "Ubuntu Condensed"))
family |
font family/families to register, default is reschola recommended. |
Called for side effects, but returns logical on process result invisibly.
Other Font helpers and shortcuts:
import_fonts()
,
install_reschola_fonts()
,
use_reschola_fonts()
Drop rows that are completely empty at specified variables. Note
tidyr::drop_na()
have a similar usage, but it drops rows containing any
missing values (so only complete observations are retained), not all
missings. remove_empty_at()
drops only those rows that have no non-missing
data at the variables specified in vars
.
remove_empty_at(.data, vars)
remove_empty_at(.data, vars)
.data |
tibble or data.frame |
vars |
variables to check for empty values, supports tidyselect syntax |
tibble or data.frame without observations with all vars
empty
airquality %>% remove_empty_at(c(Ozone, Solar.R))
airquality %>% remove_empty_at(c(Ozone, Solar.R))
This is exactly the same function as scale_*_continuous, just with different
label defaults to save repetitively setting these parameters, except that
the parameters which you would normally find inside the scales::format_*()
functions are accessible directly in the scale_[xy]_*_cz()
functions.
scale_x_percent_cz( name = waiver(), breaks = waiver(), minor_breaks = waiver(), guide = waiver(), n.breaks = NULL, labels, limits = NULL, expand = c(0.01, 0), oob = scales::censor, na.value = NA_real_, trans = "identity", position = "bottom", sec.axis = waiver(), accuracy = 1, scale = 100, prefix = "", suffix = " %", big.mark = " ", decimal.mark = ",", trim = TRUE, ... ) scale_y_percent_cz( name = waiver(), breaks = waiver(), minor_breaks = waiver(), guide = waiver(), n.breaks = NULL, labels, limits = NULL, expand = c(0.01, 0), oob = scales::censor, na.value = NA_real_, trans = "identity", position = "left", sec.axis = waiver(), accuracy = 1, scale = 100, prefix = "", suffix = " %", big.mark = " ", decimal.mark = ",", trim = TRUE, ... ) scale_x_number_cz( name = waiver(), breaks = waiver(), minor_breaks = waiver(), guide = waiver(), n.breaks = NULL, labels, limits = NULL, expand = c(0.01, 0), oob = scales::censor, na.value = NA_real_, trans = "identity", position = "bottom", sec.axis = waiver(), accuracy = 1, scale = 1, prefix = "", suffix = "", big.mark = " ", decimal.mark = ",", trim = TRUE, ... ) scale_y_number_cz( name = waiver(), breaks = waiver(), minor_breaks = waiver(), guide = waiver(), n.breaks = NULL, labels, limits = NULL, expand = c(0.01, 0), oob = scales::censor, na.value = NA_real_, trans = "identity", position = "left", sec.axis = waiver(), accuracy = 1, scale = 1, prefix = "", suffix = "", big.mark = " ", decimal.mark = ",", trim = TRUE, ... )
scale_x_percent_cz( name = waiver(), breaks = waiver(), minor_breaks = waiver(), guide = waiver(), n.breaks = NULL, labels, limits = NULL, expand = c(0.01, 0), oob = scales::censor, na.value = NA_real_, trans = "identity", position = "bottom", sec.axis = waiver(), accuracy = 1, scale = 100, prefix = "", suffix = " %", big.mark = " ", decimal.mark = ",", trim = TRUE, ... ) scale_y_percent_cz( name = waiver(), breaks = waiver(), minor_breaks = waiver(), guide = waiver(), n.breaks = NULL, labels, limits = NULL, expand = c(0.01, 0), oob = scales::censor, na.value = NA_real_, trans = "identity", position = "left", sec.axis = waiver(), accuracy = 1, scale = 100, prefix = "", suffix = " %", big.mark = " ", decimal.mark = ",", trim = TRUE, ... ) scale_x_number_cz( name = waiver(), breaks = waiver(), minor_breaks = waiver(), guide = waiver(), n.breaks = NULL, labels, limits = NULL, expand = c(0.01, 0), oob = scales::censor, na.value = NA_real_, trans = "identity", position = "bottom", sec.axis = waiver(), accuracy = 1, scale = 1, prefix = "", suffix = "", big.mark = " ", decimal.mark = ",", trim = TRUE, ... ) scale_y_number_cz( name = waiver(), breaks = waiver(), minor_breaks = waiver(), guide = waiver(), n.breaks = NULL, labels, limits = NULL, expand = c(0.01, 0), oob = scales::censor, na.value = NA_real_, trans = "identity", position = "left", sec.axis = waiver(), accuracy = 1, scale = 1, prefix = "", suffix = "", big.mark = " ", decimal.mark = ",", trim = TRUE, ... )
name |
The name of the scale. Used as axis or legend title. If
|
breaks |
One of:
|
minor_breaks |
One of:
|
guide |
guide A function used to create a guide or its name. See |
n.breaks |
An integer guiding the number of major breaks. The algorithm may choose a
slightly different number to ensure nice break labels. Will only have an effect if
|
labels |
Specifying overrides the default format (i.e. you really don't
want to do that). |
limits |
A numeric vector of length two providing limits of the scale.
Use |
expand |
same as in ggplot2 |
oob |
Function that handles limits outside of the scale limits (out of bounds). The default replaces out of bounds values with NA. |
na.value |
If |
trans |
Either the name of a transformation object, or the object itself. Built-in transformations include "asn", "atanh", "boxcox", "exp", "identity", "log", "log10", "log1p", "log2", "logit", "probability", "probit", "reciprocal", "reverse" and "sqrt". |
position |
The position of the axis. "left" or "right" for vertical scales, "top" or "bottom" for horizontal scales |
sec.axis |
specify a secondary axis |
accuracy , scale , prefix , suffix , big.mark , decimal.mark , trim
|
See [scales::comma_format()] or [scales::percent_format()] |
... |
passed on to [scales::comma_format()] or [scales::percent_format()] |
# ADD_EXAMPLES_HERE library(reschola) library(ggplot2) ggplot(mpg, aes(hwy * 100, cty / max(cty))) + geom_point() + theme_schola(family = "sans", title_family = "sans", gridlines = "scatter") + scale_y_percent_cz() + scale_x_number_cz()
# ADD_EXAMPLES_HERE library(reschola) library(ggplot2) ggplot(mpg, aes(hwy * 100, cty / max(cty))) + geom_point() + theme_schola(family = "sans", title_family = "sans", gridlines = "scatter") + scale_y_percent_cz() + scale_x_number_cz()
schola_barplot( .data, vars, group, dict = dict_from_data(.data), escape_level = "nevím", n_breaks = 11, desc = TRUE, labels = TRUE, min_label_width = 0.09, absolute_counts = TRUE, fill_cols = NULL, fill_labels = waiver(), facet_label_wrap = 115, reverse = FALSE, order_by = "chi-square differences", drop = FALSE, drop_na = TRUE, show.legend = TRUE, ... )
schola_barplot( .data, vars, group, dict = dict_from_data(.data), escape_level = "nevím", n_breaks = 11, desc = TRUE, labels = TRUE, min_label_width = 0.09, absolute_counts = TRUE, fill_cols = NULL, fill_labels = waiver(), facet_label_wrap = 115, reverse = FALSE, order_by = "chi-square differences", drop = FALSE, drop_na = TRUE, show.legend = TRUE, ... )
.data |
data with items and group variable |
vars |
vector of items, supports |
group |
group variable used to split the results, have to be logical,
where |
dict |
item code-label dictionary, if none provided, those are derived from the data. |
escape_level |
character, level of item response considered as NA |
n_breaks |
number of breaks displayed at x-axis, outer labels are automatically aligned to face inward. Defaults to 11, which results in 10% wide breaks. |
desc |
sor items in descending order? |
labels |
draw labels? |
min_label_width |
smallest percentage (0-1) to display in the plot, proportions larger than this value are shown, smaller are not. |
absolute_counts |
draw labels and absolute counts in parentheses? |
fill_cols |
colors to be used for item categories, defaults to NULL, meaning standard RdYlBu palette will be used |
fill_labels |
character vector or function taking breaks and returning labels for fill aesthetic |
facet_label_wrap |
width of facet label to wrap |
reverse |
if TRUE, reverse colors |
order_by |
how to order the items. chi-square differences (default) computes chi-square test for every item and sort them by largest X2 statistic to smallest (if desc = TRUE) |
drop |
Drop unobserved levels form the legend? Defaults to |
drop_na |
Drop |
show.legend |
logical. Should this layer be included in the legends?
|
... |
Arguments passed on to
|
Object of class "gg", "ggplot".
Other Making charts:
flush_axis
,
plot_lollipop()
,
prepare_lollipop_data()
,
theme_schola()
Turns item codes into labels by looking up provided dictionary and applies them as facet labels.
schola_labeller(dict, width = 80)
schola_labeller(dict, width = 80)
dict |
code-label dictionary as named character vector, see
|
width |
maximal string length per line, if |
object of class labeller
, to be used in facet_*
ggplot2
functions.
Function called in the output section of the YAML header (see examples
below), instructing knitr
to use the standard Schola PDF document format.
If you run into any problem using the Czech language, consult this function
details first.
schola_pdf( num_format = NULL, number_sections = FALSE, toc = TRUE, template = find_resource("schola_pdf", "schola_template.tex"), latex_engine = "xelatex", fig_crop = FALSE, document_class = "report", ... )
schola_pdf( num_format = NULL, number_sections = FALSE, toc = TRUE, template = find_resource("schola_pdf", "schola_template.tex"), latex_engine = "xelatex", fig_crop = FALSE, document_class = "report", ... )
num_format |
Character, if |
number_sections |
Logical, |
toc |
Logical, |
template |
Character, path to the |
latex_engine |
Character, engine used for |
fig_crop |
logical, whether to crop PDF figures. Defaults to |
document_class |
Character, one of standard LaTeX document class.
Defaults to |
... |
Arguments passed on to
|
A modified bookdown::pdf_document2
with the standard Schola
formatting.
babel
hyphenation warningYou may encounter a following warning when your document is being "compiled"
to .pdf
format:
Warning: Package babel Warning: No hyphenation patterns were preloaded for Warning: (babel) the language 'Czech' into the format. Warning: (babel) Please, configure your TeX system to add them and Warning: (babel) rebuild the format. Now I will use the patterns Warning: (babel) preloaded for \language=0 instead on input line 53.
This usually solves by calling tinytex::tlmgr_install("hyphen-czech")
(if
you are a {tinytex}
user).
Jan Netik
Other Report templates and formats:
copy_schola_template()
,
open_schola_template()
,
schola_word()
,
schola_word2()
## Not run: # in YAML header ------ output: reschola::schola_pdf: toc:false ## End(Not run)
## Not run: # in YAML header ------ output: reschola::schola_pdf: toc:false ## End(Not run)
This is a function called in the output of the YAML of the Rmd file to specify using the standard Schola word document formatting.
schola_word( reference_docx = find_resource("schola_word", "template.docx"), ... )
schola_word( reference_docx = find_resource("schola_word", "template.docx"), ... )
reference_docx |
Path to custom template. By default, the built-in one is used. |
... |
Arguments passed on to |
If no template is specified, the function will use the reschola
's
default template. Path to template is relative to document being compiled.
See the examples below, or read the
bookdown
manual
for more details and for a brief guide to Word templating).
A modified word_document2
with the standard Schola formatting.
Petr Bouchal
Jan Netik
Other Report templates and formats:
copy_schola_template()
,
open_schola_template()
,
schola_pdf()
,
schola_word2()
## Not run: # # with the default template output: reschola::schola_word # with a user-specified template output: reschola::schola_word: reference_docx:template.docx ## End(Not run)
## Not run: # # with the default template output: reschola::schola_word # with a user-specified template output: reschola::schola_word: reference_docx:template.docx ## End(Not run)
This is a function called in the output part of the YAML section of the Rmd file while using the Word template provided at the same place (see example below).
schola_word2(...)
schola_word2(...)
... |
Arguments to be passed to |
Compared to schola_word
, this "version" comes with no predefined
template, so the user can utilize a template stated in YAML header (see the
example below, or read the bookdown
manual for
more details and for a brief guide to Word templating).
A modified word_document2
with the standard Schola formatting, but
without hard-coded and unchangeable template.
Jan Netik
Other Report templates and formats:
copy_schola_template()
,
open_schola_template()
,
schola_pdf()
,
schola_word()
## Not run: output: reschola::schola_word2: reference_docx:template.docx ## End(Not run)
## Not run: output: reschola::schola_word2: reference_docx:template.docx ## End(Not run)
Get your raw total score transformed to stens, i.e., with the mean of 5.5 and a standard deviation of 2. See the Wikipedia article on the topic for more details.
sten(score, standardize = FALSE, bounds = TRUE)
sten(score, standardize = FALSE, bounds = TRUE)
score |
numeric vector of scores to transform |
standardize |
logical, center and scale |
bounds |
limit result to 1-10 scale, TRUE by default |
numeric vector of transformed scores
rnorm(10) %>% sten()
rnorm(10) %>% sten()
A wrapper around theme()
which provides several shortcuts to setting common
options and several defaults. See more in Details.
theme_schola( gridlines = c("y", "x", "both", "scatter"), base_size = 11, family = "Ubuntu Condensed", title_family = "Ubuntu", margins = TRUE, plot.title.position = "plot", axis_titles = TRUE, multiplot = FALSE, ... )
theme_schola( gridlines = c("y", "x", "both", "scatter"), base_size = 11, family = "Ubuntu Condensed", title_family = "Ubuntu", margins = TRUE, plot.title.position = "plot", axis_titles = TRUE, multiplot = FALSE, ... )
gridlines |
Whether to display major gridlines along |
base_size |
Numeric text size in pts, affects all text in plot. Defaults to 11. |
family , title_family
|
font family to use for the (title of the) plot.
Defaults to |
margins |
logical, whether to draw margins around the plot or not (the default). |
plot.title.position |
where to align the title. Either "plot" (the
default, difference from |
axis_titles |
logical, draw axis titles? Defaults to |
multiplot |
if set to TRUE, provides better styling for small multiples
created using |
... |
Arguments passed on to
|
In particular, the theme: - displays only major gridlines, allowing you to quickly switch which ones; gridlines are thinner, panel has white background
provides quick option to draw a scatter with grey background - switches defaults for title alignment - turns axis labels off by default: in practice, x axes are often obvious and y axes are better documented in a subtitle - sets backgrounds to a schola-style shade - sets plot title in bold and 120% of base_size
All the changed defaults can be overriden by another call to theme()
.
See "Making charts" vignette for more complex examples: vignette('charts', package = 'reschola')
.
a ggtheme object
The default fonts - Ubuntu and Ubuntu Condensed - are contained in this
package and can be registered with the system using
register_reschola_fonts()
. You should then install them onto your system
like any font, using files in the directories described in the
register_reschola_fonts()
messsage.
Other Making charts:
flush_axis
,
plot_lollipop()
,
prepare_lollipop_data()
,
schola_barplot()
library(ggplot2) # NOTE when `theme_schola()` is used in these examples, fonts # are set to 'sans' to pass checks on computers without the # Ubuntu included. If you have these fonts (see Note) you can # leave these parameters at their default values. use_reschola_fonts("sans") # the basic plot for illustration, theme not used p <- ggplot(mpg) + geom_bar(aes(y = class)) + labs(title = "Lots of cars", subtitle = "Count of numbers") # using `theme_schola()` defaults p + theme_schola("x", family = "sans", title_family = "sans") # in combination with `flush_axis`: p + theme_schola("x", family = "sans", title_family = "sans") + scale_x_continuous(expand = flush_axis) # scatter ggplot(mpg) + geom_point(aes(cty, hwy)) + theme_schola("scatter", family = "sans", title_family = "sans") + labs(title = "Lots of cars", subtitle = "Point by point") # Smaller text, flush alignment ggplot(mpg) + geom_point(aes(cty, hwy)) + theme_schola("scatter", base_size = 9, family = "sans", title_family = "sans" ) + labs(title = "Lots of cars", subtitle = "Point by point") # Override defaults changed inside `theme_schola()` ggplot(mpg) + geom_point(aes(cty, hwy)) + theme_schola("scatter", base_size = 9, family = "sans", title_family = "sans" ) + labs(title = "Lots of cars", subtitle = "Point by point") + theme(panel.background = element_rect(fill = "lightpink"))
library(ggplot2) # NOTE when `theme_schola()` is used in these examples, fonts # are set to 'sans' to pass checks on computers without the # Ubuntu included. If you have these fonts (see Note) you can # leave these parameters at their default values. use_reschola_fonts("sans") # the basic plot for illustration, theme not used p <- ggplot(mpg) + geom_bar(aes(y = class)) + labs(title = "Lots of cars", subtitle = "Count of numbers") # using `theme_schola()` defaults p + theme_schola("x", family = "sans", title_family = "sans") # in combination with `flush_axis`: p + theme_schola("x", family = "sans", title_family = "sans") + scale_x_continuous(expand = flush_axis) # scatter ggplot(mpg) + geom_point(aes(cty, hwy)) + theme_schola("scatter", family = "sans", title_family = "sans") + labs(title = "Lots of cars", subtitle = "Point by point") # Smaller text, flush alignment ggplot(mpg) + geom_point(aes(cty, hwy)) + theme_schola("scatter", base_size = 9, family = "sans", title_family = "sans" ) + labs(title = "Lots of cars", subtitle = "Point by point") # Override defaults changed inside `theme_schola()` ggplot(mpg) + geom_point(aes(cty, hwy)) + theme_schola("scatter", base_size = 9, family = "sans", title_family = "sans" ) + labs(title = "Lots of cars", subtitle = "Point by point") + theme(panel.background = element_rect(fill = "lightpink"))
Sets {ggplot2}
defaults for most text-based geoms in {ggplot2}
,
{ggtext}
, and {ggrepel}
.
use_reschola_fonts( family = "Ubuntu Condensed", face = "plain", size = 3.5, color = "#2b2b2b" ) set_reschola_ggplot_fonts( family = "Ubuntu Condensed", face = "plain", size = 3.5, color = "#2b2b2b" )
use_reschola_fonts( family = "Ubuntu Condensed", face = "plain", size = 3.5, color = "#2b2b2b" ) set_reschola_ggplot_fonts( family = "Ubuntu Condensed", face = "plain", size = 3.5, color = "#2b2b2b" )
family |
font family, defaults to reschola recommended |
face |
font face |
size |
font size |
color |
font color |
Geoms covered: "text", "label", "richtext", "text_box", "text_repel", and "label_repel".
Other Font helpers and shortcuts:
import_fonts()
,
install_reschola_fonts()
,
register_reschola_fonts()
Create HTML span tag with text and color style
with_clr(text, color = "black", alpha = 1, ...)
with_clr(text, color = "black", alpha = 1, ...)
text |
character, text that will be colored. |
color |
character, color applied to the text, defaults to black. |
alpha |
numeric, opacity in interval 0–1, where 1 is no transparency, i.e. full opacity |
... |
Arguments passed on to
|
an object of class shiny.tag
, coercible to character
html <- paste0( with_clr("Red", "red"), ", ", with_clr("green", "green"), " and ", with_clr("blue", "blue"), " are the basic colors." ) library(ggplot2) library(ggtext) ggplot() + geom_richtext(aes(x = 1, y = 1, label = html), size = 8) + theme_void()
html <- paste0( with_clr("Red", "red"), ", ", with_clr("green", "green"), " and ", with_clr("blue", "blue"), " are the basic colors." ) library(ggplot2) library(ggtext) ggplot() + geom_richtext(aes(x = 1, y = 1, label = html), size = 8) + theme_void()