Learn R Programming

exams.forge (version 1.0.10)

lsumprod: Supporting Functions for Math LaTeX Output

Description

lsumprod creates a latex printout of \(\sum_i x_i y_i\) with brackets if \(x_i\) or \(y_i\) starts with a -.

lsum creates a latex printout of \(x\) as sum.

lprod creates a latex printout of \(x\) as product.

lvec creates a latex printout of \(x\) as vector.

lmean creates a latex printout as \(\frac{x_1+...+x_n}{n}\).

lvar creates a latex printout as \(\frac{(x_1-xbar)^2+...+(x_n-xbar)^2}{n}\).

lbr creates a latex printout of \(x\) with brackets if \(x\) starts with a -.

lsgn creates a latex printout of \(x\) with a plus or minus at the beginning.

Usage

lsumprod(..., br = "(")

lsum(x)

lprod(x)

lvec( x, left = c("(", "[", "{", "|", "||", "<", "a",="" "c",="" "f"),="" right="NULL," collapse=", " )<="" p="">

lmean(x)

lvar(x, mu = NULL, br = "(")

lbr(x, br = c("(", "[", "{", "|", "||", "<", "a",="" "c",="" "f"),="" subset="NULL)

lsgn(x)

latex_sumprod(..., br = "(")

latex_sum(x)

latex_product(x)

latex_mean(x)

latex_var(x, mu = NULL, br = "(")

latex_bracket( x, br = c("(", "[", "{", "|", "||", "<", "a",="" "c",="" "f"),="" subset="NULL" )<="" p="">

latex_pmsign(x)

Value

A character.

Arguments

...

further input values

br, left, right

character: which brackets to use. The possibilities are:

  • ( (default) uses \left( and \right(,

  • [ use \left[ and \right],

  • { use \left\{ and \right\},

  • | use \left| and \right|,

  • || uses \left\| and \right\|,

  • <, a use \left\langle and \right\rangle,

  • c use \left\lceil and \right\rceil, and

  • f use \left\lfloor and \right\rfloor.

x

numeric: input values

collapse

character: an optional character string to separate the results (default: ', ')

mu

numeric: population mean (default: NULL)

subset

logical: indicates which elements have brackets added (default: NULL = all elements starting with -); missing values are taken as false.

Examples

Run this code
lsumprod(-2:2, (1:5)/10)
lbr(-2:2)
lsum(-2:2)
lmean(-2:2)
lvec(-2:2)
lvec(-2:2, '[')
lvec(0:1, '(', ']')

Run the code above in your browser using DataLab