| Title: | Dependencies for the 'jamovi' Framework |
|---|---|
| Description: | A framework for creating rich interactive analyses for the jamovi platform (see <https://www.jamovi.org> for more information). |
| Authors: | Jonathon Love [aut, cre, cph] |
| Maintainer: | Jonathon Love <jon@thon.cc> |
| License: | GPL (>= 2) |
| Version: | 28.3 |
| Built: | 2026-10-15 06:07:05 UTC |
| Source: | https://github.com/jamovi/jamovi |
A framework for creating rich interactive analyses for the jamovi platform (see https://www.jamovi.org for more information).
Numbers in results tables are formatted as jamovi formats them: each
column is given enough decimal places for its smallest value to have the
required number of significant figures, p-values are given to a fixed
number of decimal places (and smaller ones are shown as < .001), and
integers are shown as they are.
This is set with the jmvcore.format option, a list of:
style: 'sf' (significant figures) or 'dp' (decimal places), for
values. Default 'sf'
digits: how many, for values. Default 4
pStyle: 'sf' or 'dp', for p-values. Default 'dp'
pDigits: how many, for p-values. Default 3
Any of these may be given, and the rest take their defaults. Setting the
option replaces any earlier setting, rather than adding to it. The
defaults are jamovi's, but with a significant figure more for values
(digits=3 gives jamovi's own formatting).
The decimal symbol is taken from R's OutDec option.
When a document is knitted to html, results are rendered as html, as jamovi exports them: tables, headings, notes and plots. Other output formats get the same text as the console.
A chunk may set its own number format, over jmvcore.format, with the
jmv-format chunk option:
#| jmv-format: {digits: 5}
jmv::ttestIS(ToothGrowth, vars='len', group='supp')
Maintainer: Jonathon Love jon@thon.cc [copyright holder]
Authors:
Jonathon Love jon@thon.cc [copyright holder]
Useful links:
Report bugs at https://github.com/jamovi/jamovi/issues
## Not run: # 5 significant figures, and p-values to 4 decimal places options(jmvcore.format=list(digits=5, pDigits=4)) # jamovi's own formatting options(jmvcore.format=list(digits=3)) # back to the defaults options(jmvcore.format=NULL) ## End(Not run)## Not run: # 5 significant figures, and p-values to 4 decimal places options(jmvcore.format=list(digits=5, pDigits=4)) # jamovi's own formatting options(jmvcore.format=list(digits=3)) # back to the defaults options(jmvcore.format=NULL) ## End(Not run)
Designate string as translated
.(text, n = 1).(text, n = 1)
text |
the string to translate |
n |
the number (if applicable) for pluralisation |
Designate string as client-side translated
..(format, values = NULL)..(format, values = NULL)
format |
a format string |
values |
a string or named list of strings to substitute |
Accepts formula-like input, converts it with [stats::as.formula()], validates it using [validateSafeFormula()], and returns the formula.
asFormula(object, env = parent.frame(), additional_allowed_functions = NULL)asFormula(object, env = parent.frame(), additional_allowed_functions = NULL)
object |
A formula-like object (typically a character string or formula). |
env |
The environment to use when parsing character formulas. |
additional_allowed_functions |
Optional character vector of extra function names to permit for this conversion and validation call. |
A validated formula object.
Available from jamovi 2.7.27.
Determines whether an object is or can be converted to numeric
canBeNumeric(object)canBeNumeric(object)
object |
the object |
Cell.BEGIN_GROUP adds spacing above a cell
Cell.BEGIN_GROUP Cell.END_GROUP Cell.BEGIN_END_GROUP Cell.NEGATIVE Cell.INDENTEDCell.BEGIN_GROUP Cell.END_GROUP Cell.BEGIN_END_GROUP Cell.NEGATIVE Cell.INDENTED
Cell.END_GROUP add spacing below a cell
Cell.BEGIN_END_GROUP add spacing above and below a cell
Cell.NEGATIVE specifies that the cells contents is negative
## Not run: table$addFormat(rowNo=1, col=1, Cell.BEGIN_END_GROUP) ## End(Not run)## Not run: table$addFormat(rowNo=1, col=1, Cell.BEGIN_END_GROUP) ## End(Not run)
A function that creates a color palette
colorPalette(n = 5, pal = "jmv", type = "fill")colorPalette(n = 5, pal = "jmv", type = "fill")
n |
Number of colors needed |
pal |
Color palette name |
type |
'fill' or 'color' |
a vector of hex color codes
Compose a formula string
composeFormula(lht, rht)composeFormula(lht, rht)
lht |
list of character vectors making up the left |
rht |
list of character vectors making up the right |
a string representation of the formula
composeFormula(list('a', 'b', c('a', 'b'))) # ~a+b+a:b composeFormula('f', list('a', 'b', c('a', 'b'))) # "f~a+b+a:b" composeFormula('with spaces', list('a', 'b', c('a', 'b'))) '`with spaces`~a+b+a:b'composeFormula(list('a', 'b', c('a', 'b'))) # ~a+b+a:b composeFormula('f', list('a', 'b', c('a', 'b'))) # "f~a+b+a:b" composeFormula('with spaces', list('a', 'b', c('a', 'b'))) '`with spaces`~a+b+a:b'
Compose and decompose interaction terms to and from their components
composeTerm(components) composeTerms(listOfComponents) decomposeTerm(term) decomposeTerms(terms)composeTerm(components) composeTerms(listOfComponents) decomposeTerm(term) decomposeTerms(terms)
components |
a character vectors of components |
listOfComponents |
a list of character vectors of components |
term |
a string with components separated with colons |
terms |
a character vector of components separated with colons |
composeTerm(c('a', 'b', 'c')) # 'a:b:c' composeTerm(c('a', 'b', 'with space')) # 'a:b:`with space`' decomposeTerm('a:b:c') # c('a', 'b', 'c') decomposeTerm('a:b:`with space`') # c('a', 'b', 'with space')composeTerm(c('a', 'b', 'c')) # 'a:b:c' composeTerm(c('a', 'b', 'with space')) # 'a:b:`with space`' decomposeTerm('a:b:c') # c('a', 'b', 'c') decomposeTerm('a:b:`with space`') # c('a', 'b', 'with space')
Construct a formula string
constructFormula(dep = NULL, terms)constructFormula(dep = NULL, terms)
dep |
the name of the dependent variable |
terms |
list of character vectors making up the terms |
a string representation of the formula
constructFormula(terms=list('a', 'b', c('a', 'b'))) # a+b+a:b constructFormula('f', list('a', 'b', c('a', 'b'))) # "f~a+b+a:b" constructFormula('with spaces', list('a', 'b', c('a', 'b'))) '`with spaces`~a+b+a:b'constructFormula(terms=list('a', 'b', c('a', 'b'))) # a+b+a:b constructFormula('f', list('a', 'b', c('a', 'b'))) # "f~a+b+a:b" constructFormula('with spaces', list('a', 'b', c('a', 'b'))) '`with spaces`~a+b+a:b'
Used internally by jamovi
create(ns, name, optionsPB, datasetId, analysisId, revision)create(ns, name, optionsPB, datasetId, analysisId, revision)
ns |
package name |
name |
analysis name |
optionsPB |
options protobuf object |
datasetId |
dataset id |
analysisId |
analysis id |
revision |
revision |
These functions are convenience functions for creating and throwing errors.
createError(formats, code = NULL, ...) reject(formats, code = NULL, ...)createError(formats, code = NULL, ...) reject(formats, code = NULL, ...)
formats |
a format string which is passed to |
code |
an error code |
... |
additional arguments passed to |
Decompose a formula
decomposeFormula(formula)decomposeFormula(formula)
formula |
the formula to decompose |
a list of lists of the formulas components
Extracts the error message from an error object
extractErrorMessage(error)extractErrorMessage(error)
error |
an error object |
Substitutes the arguments into the argument str. See the examples below.
format(str, ..., context = "normal")format(str, ..., context = "normal")
str |
the format string |
... |
the arguments to substitute into the string |
context |
'normal' or 'R' |
the resultant string
jmvcore::format('the {} was delish', 'fish') # 'the fish was delish' jmvcore::format('the {} was more delish than the {}', 'fish', 'cow') # 'the fish was more delish than the cow' jmvcore::format('the {1} was more delish than the {0}', 'fish', 'cow') # 'the cow was more delish than the fish' jmvcore::format('the {what} and the {which}', which='fish', what='cow') # 'the cow and the fish' jmvcore::format('that is simply not {}', TRUE) # 'that is simply not true' jmvcore::format('that is simply not {}', TRUE, context='R') # 'that is simply not TRUE'jmvcore::format('the {} was delish', 'fish') # 'the fish was delish' jmvcore::format('the {} was more delish than the {}', 'fish', 'cow') # 'the fish was more delish than the cow' jmvcore::format('the {1} was more delish than the {0}', 'fish', 'cow') # 'the cow was more delish than the fish' jmvcore::format('the {what} and the {which}', which='fish', what='cow') # 'the cow and the fish' jmvcore::format('that is simply not {}', TRUE) # 'that is simply not true' jmvcore::format('that is simply not {}', TRUE, context='R') # 'that is simply not TRUE'
Escape HTML special characters
htmlEscape(text, attribute = FALSE)htmlEscape(text, attribute = FALSE)
text |
a character vector to escape |
attribute |
logical; if TRUE, also escapes quotes and newlines for use in HTML attribute values |
the escaped character vector
Determine if an object is an error
isError(object)isError(object)
object |
the object to test |
TRUE if the object is an error
Marshal the data from an environment into a data frame
marshalData(env, ...)marshalData(env, ...)
env |
the environment to marshal from |
... |
the variables to marshal |
a data frame
Marshal a formula into options
marshalFormula( formula, data, from = "rhs", type = "vars", permitted = c("numeric", "factor"), subset = ":", required = FALSE )marshalFormula( formula, data, from = "rhs", type = "vars", permitted = c("numeric", "factor"), subset = ":", required = FALSE )
formula |
the formula |
data |
a data frame to marshal the data from |
from |
'rhs' or 'lhs', which side of the formula should be marshalled |
type |
'vars' or 'terms', the type of the option be marshalled to |
permitted |
the types of data the option permits |
subset |
a subset of the formula to marshal |
required |
whether this marshall is required or not |
Determines the index where an item appears
matchSet(x, table)matchSet(x, table)
x |
the item to find |
table |
the object to search |
the index of where the item appears, or -1 if it isn't present
removes all rows from the data frame which contain missing values (NA)
naOmit(object)naOmit(object)
object |
the object to remove missing values from |
this function is equivalent to na.omit from the stats package,
however it preserves attributes on columns in data frames
Evaluates a quosure This is intended for use by classes overriding Analysis
resolveQuo(quo)resolveQuo(quo)
quo |
the quosure to evaluate |
the value of the quosure
Shorthand equivalent to subset(df, select=columnNames), however
it additionally preserves attributes on the columns and the data frame
select(df, columnNames)select(df, columnNames)
df |
the data frame |
columnNames |
the names of the columns to make up the new data frame |
the new data frame
Converts basic R object into their source representation
sourcify(object, indent = "")sourcify(object, indent = "")
object |
the object to convert to source |
indent |
the level of indentation to use |
a string of the equivalent source code
sourcify(NULL) # 'NULL' sourcify(c(1,2,3)) # 'c(1,2,3)' l <- list(a=7) l[['b']] <- 3 l[['c']] <- list(d=3, e=4) sourcify(l) # 'list( # a=7, # b=3, # c=list( # d=3, # e=4))'sourcify(NULL) # 'NULL' sourcify(c(1,2,3)) # 'c(1,2,3)' l <- list(a=7) l[['b']] <- 3 l[['c']] <- list(d=3, e=4) sourcify(l) # 'list( # a=7, # b=3, # c=list( # d=3, # e=4))'
Same as base::startsWith() and base::endsWith() except
available for R < 3.3
startsWith(x, prefix) endsWith(x, suffix)startsWith(x, prefix) endsWith(x, suffix)
x |
a string to test |
prefix |
a string to test the presence of |
suffix |
a string to test the presence of |
Converts a term (a vector of components) into a string for display purposes
stringifyTerm(components, sep = getOption("jmvTermSep", ":"), raise = FALSE)stringifyTerm(components, sep = getOption("jmvTermSep", ":"), raise = FALSE)
components |
a character vector of components |
sep |
a separator to go between the components |
raise |
whether duplicates should be raised to powers |
the components joined together into a string for disply
stringifyTerm(c('a', 'b', 'c')) # "a:b:c" stringifyTerm(c('a', 'b', 'c'), sep=' * ') # "a * b * c" options('jmvTermSep', ' * ') stringifyTerm(c('a', 'b', 'c')) # "a * b * c" #' stringifyTerm(c('`quoted`', 'b', 'c')) # "quoted * b * c"stringifyTerm(c('a', 'b', 'c')) # "a:b:c" stringifyTerm(c('a', 'b', 'c'), sep=' * ') # "a * b * c" options('jmvTermSep', ' * ') stringifyTerm(c('a', 'b', 'c')) # "a * b * c" #' stringifyTerm(c('`quoted`', 'b', 'c')) # "quoted * b * c"
Creates the default jmv ggplot2 theme
theme_default(base_size = 16, scale = "none", palette = "jmv")theme_default(base_size = 16, scale = "none", palette = "jmv")
base_size |
Font size |
scale |
'none' or 'discrete' |
palette |
Color palette name |
the default jmv ggplot2 theme
Creates the hadley jmv ggplot2 theme
theme_hadley(base_size = 16, scale = "none", palette = "jmv")theme_hadley(base_size = 16, scale = "none", palette = "jmv")
base_size |
Font size |
scale |
'none' or 'discrete' |
palette |
Color palette name |
the hadley jmv ggplot2 theme
Creates the minimal jmv ggplot2 theme
theme_min(base_size = 16, scale = "none", palette = "jmv")theme_min(base_size = 16, scale = "none", palette = "jmv")
base_size |
Font size |
scale |
'none' or 'discrete' |
palette |
Color palette name |
the minimal jmv ggplot2 theme
Creates the spss jmv ggplot2 theme
theme_spss(base_size = 16, scale = "none", palette = "jmv")theme_spss(base_size = 16, scale = "none", palette = "jmv")
base_size |
Font size |
scale |
'none' or 'discrete' |
palette |
Color palette name |
the spss jmv ggplot2 theme
Note: uses the . and _ characters rather than + and / allowing these to be used as variable names
toB64(names) fromB64(names)toB64(names) fromB64(names)
names |
the names to be converted base64 |
Similar to as.numeric, however if the object has a values
attribute attached, these are used as the numeric values
toNumeric(object)toNumeric(object)
object |
the vector to convert |
if the expression fails, NaN is returned silently
tryNaN(expr)tryNaN(expr)
expr |
an expression to evaluate |
the result, or NaN on failure
Secure formula validation using allowlist approach Prevents code injection while allowing legitimate statistical formulas
validateSafeFormula(fmla, additional_allowed_functions = NULL)validateSafeFormula(fmla, additional_allowed_functions = NULL)
fmla |
A formula object to validate. |
additional_allowed_functions |
Optional character vector of extra function names to permit for this validation call. |
Invisibly returns 'NULL'. Throws an error if the formula contains security violations.
# Safe usage: validateSafeFormula(y ~ x + z) validateSafeFormula(y ~ I(x^2) + log(z)) ## Not run: # Blocks dangerous code (throws an error): validateSafeFormula(y ~ I(system('whoami'))) ## End(Not run)# Safe usage: validateSafeFormula(y ~ x + z) validateSafeFormula(y ~ I(x^2) + log(z)) ## Not run: # Blocks dangerous code (throws an error): validateSafeFormula(y ~ I(system('whoami'))) ## End(Not run)