Title: | Apps and Data for the Book "Introduction to Statistics" |
---|---|
Description: | Functions, Shiny apps and data for the book "Introduction to Statistics" by Wolfgang Karl Härdle, Sigbert Klinke, and Bernd Rönz (2015) <doi:10.1007/978-3-319-17704-5>. |
Authors: | Sigbert Klinke [aut, cre] |
Maintainer: | Sigbert Klinke <[email protected]> |
License: | GPL-3 |
Version: | 0.1.4 |
Built: | 2025-02-02 03:25:06 UTC |
Source: | https://github.com/sigbertklinke/hkrbook |
Checks if a package is installed without loading it. Returns a logical vector with TRUE
or FALSE
for each package checked.
checkPackages( ..., add = c("highlight", "formatR", "shiny", "shinydashboard", "shinydashboardPlus", "DT") )
checkPackages( ..., add = c("highlight", "formatR", "shiny", "shinydashboard", "shinydashboardPlus", "DT") )
... |
character: name(s) of package |
add |
character: names of default packages to check (default: |
TRUE
if successful otherweise an error will be thrown
checkPackages("graphics", add=NULL) # checks if 'graphics' is installed if (interactive()) checkPackages("graphics") # checks if 'graphics', 'shiny', ... are installed
checkPackages("graphics", add=NULL) # checks if 'graphics' is installed if (interactive()) checkPackages("graphics") # checks if 'graphics', 'shiny', ... are installed
Computes approximate distribution parameters for the binomial, hypergeometric, Poisson, Exponential and normal distribution for a given mean (and standard deviation). With the sample and the population size the computation can be influenced.
distributionParams(mean, sd, n = 30, N = 60)
distributionParams(mean, sd, n = 30, N = 60)
mean |
numeric: mean |
sd |
numeric: standard deviation (only used for the normal distribution) |
n |
integer: sample size (default: |
N |
integer: population size (default: |
a list of parameters for each distribution
# Compute approx. paramaters for a binomial distribution distributionParams(mean=30*0.5, sd=sqrt(30*0.5*0.5))
# Compute approx. paramaters for a binomial distribution distributionParams(mean=30*0.5, sd=sqrt(30*0.5*0.5))
Returns a translation from loaded PO-file. If the message is not found in the PO-file then original text will be returned.
gettext(msg, utype = "vector")
gettext(msg, utype = "vector")
msg |
character: message(s) to translate |
utype |
character: how to return the translated message as vector or named list |
translated messages
msgs <- c("two.sided", "less", "greater") gettext(msgs) # for use in Shiny "choices" gettext(msgs, "name") gettext(msgs, "numeric")
msgs <- c("two.sided", "less", "greater") gettext(msgs) # for use in Shiny "choices" gettext(msgs, "name") gettext(msgs, "numeric")
hm_cell
or hm_index
modify a data cell format (fmt="%s"
), value (unnamed parameter) or style (text_align="left"
)
hm_col
or hm_row
modify a row or column format (fmt="%s"
), value (unnamed parameter) or style (text_align="left"
)
hm_cell(x, row = NULL, col = NULL, ..., byrow = FALSE) hm_index(x, ind, ...) hm_title(x, ...) hm_colmargintitle(x, ...) hm_rowmargintitle(x, ...) hm_total(x, ...) hm_table(x, ...) hm_row(x, ind, ...) hm_col(x, ind, ...) hm_colmargin(x, ind, ...) hm_rowmargin(x, ind, ...) hm_tr(x, ind, ...)
hm_cell(x, row = NULL, col = NULL, ..., byrow = FALSE) hm_index(x, ind, ...) hm_title(x, ...) hm_colmargintitle(x, ...) hm_rowmargintitle(x, ...) hm_total(x, ...) hm_table(x, ...) hm_row(x, ind, ...) hm_col(x, ind, ...) hm_colmargin(x, ind, ...) hm_rowmargin(x, ind, ...) hm_tr(x, ind, ...)
x |
html_matrix object |
row |
integer: row(s) to access |
col |
integer: column(s) to access |
... |
elements to change |
byrow |
logical: order indices by row or column (default: |
ind |
integer vector or matrix: access various (row and columns) elements (first column: row, second column: column) |
modified html_matrix object
l <- html_matrix(matrix(1:6, ncol=2)) # replace l[1,1] by NA hm_cell(l, 1, 1, NA) # replace l[1,1] by NA and set the text_align to center hm_cell(l, 1, 1, NA, text_align="center") # replace l[1,3] and l[2,1] by NA rcind <- cbind(c(1,3), c(2, 1)) hm_index(l, rcind, NA) # set a new title hm_title(l, "new title") # set a new row or column title hm_row(l, 2, "row 2") hm_col(l, 1, "col 1") # set fmt by column or row print(hm_cell(l, fmt=c("%.0f", "%.1f", "%.2f"), byrow=FALSE), which="fmt") print(hm_cell(l, fmt=c("%.0f", "%.1f"), byrow=TRUE), which="fmt")
l <- html_matrix(matrix(1:6, ncol=2)) # replace l[1,1] by NA hm_cell(l, 1, 1, NA) # replace l[1,1] by NA and set the text_align to center hm_cell(l, 1, 1, NA, text_align="center") # replace l[1,3] and l[2,1] by NA rcind <- cbind(c(1,3), c(2, 1)) hm_index(l, rcind, NA) # set a new title hm_title(l, "new title") # set a new row or column title hm_row(l, 2, "row 2") hm_col(l, 1, "col 1") # set fmt by column or row print(hm_cell(l, fmt=c("%.0f", "%.1f", "%.2f"), byrow=FALSE), which="fmt") print(hm_cell(l, fmt=c("%.0f", "%.1f"), byrow=TRUE), which="fmt")
Creates from a vector, matrix, array, or table a HTML representation of it. The HTML representation has one column and row more than the data. The additional row and column are used to have a title (top left), the column names (top), and the row names (left).
You can set the style attributes (<td style="...">
) via hm_cell
, hm_title
, hm_col
, and hm_row
.
For example: hm_cell(hm, 1, 1, text_align="right")
will lead to (<td style="text-align:right;">
) for the cell (1,1) and any
unnamed element will change the cell value.
Note: since -
is an operator in R, we use _
instead. Of course, you could use "text-align"="right"
, but I'am lazy.
html_matrix(x, ...) ## Default S3 method: html_matrix( x, ..., byrow = FALSE, numeric = list(text_align = "right"), integer = list(text_align = "right"), char = list(text_align = "left"), logical = list(text_align = "right"), border = "#999999" )
html_matrix(x, ...) ## Default S3 method: html_matrix( x, ..., byrow = FALSE, numeric = list(text_align = "right"), integer = list(text_align = "right"), char = list(text_align = "left"), logical = list(text_align = "right"), border = "#999999" )
x |
vector, matrix, array, table or html_matrix: input |
... |
further parameters |
byrow |
logical: create a row or column matrix if |
numeric |
list: list of HTML style properties for a cell if |
integer |
list: list of HTML style properties for a cell if |
char |
list: list of HTML style properties for a cell if |
logical |
list: list of HTML style properties for a cell if |
border |
character: vector of background color for a border cell (default: |
html_matrix
returns a html_matrix, print
returns invisible a character matrix
m <- matrix(1:6, ncol=2) m l <- html_matrix(m) l
m <- matrix(1:6, ncol=2) m l <- html_matrix(m) l
Creates a HTML table from a two dimensional table object.
htmlTable( tab, vars = NULL, lines = NULL, cex = 1, title = "", rowsum = NULL, colsum = NULL, fmt = "%.0f", total = NULL, ... )
htmlTable( tab, vars = NULL, lines = NULL, cex = 1, title = "", rowsum = NULL, colsum = NULL, fmt = "%.0f", total = NULL, ... )
tab |
two dimensional table object |
vars |
character: names of row and column variable |
lines |
character: final line (default: |
cex |
numeric: font size (default: |
title |
character: table title (default: |
rowsum |
character: add row sums at the right (default: |
colsum |
character: add column sums at the bottom (default: |
fmt |
character: format string for |
total |
character: add the grand total at the bottom left (default: |
... |
further parameters given to |
html_matrix object
htab <- htmlTable(apply(Titanic,1:2,sum), c("Sex", "Class"), title="Titanic") toHTML(htab, browser=interactive())
htab <- htmlTable(apply(Titanic,1:2,sum), c("Sex", "Class"), title="Titanic") toHTML(htab, browser=interactive())
Checks if x
is between lower
and upper
,
in_range(x, lower, upper, rightmost.closed = TRUE, left.open = FALSE)
in_range(x, lower, upper, rightmost.closed = TRUE, left.open = FALSE)
x |
numeric: vaklues to check |
lower |
numeric: lower bound |
upper |
numeric: upper bound |
rightmost.closed |
logical: if true then |
left.open |
logical: if true then |
a logical vector whether x
is in range or not
in_range(-1:2, 0, 1)
in_range(-1:2, 0, 1)
Checks if txt
contains only ASCII characters.
is.ASCII(txt)
is.ASCII(txt)
txt |
character: text to check |
logical
is.ASCII("Congratulations") is.ASCII("Herzlichen Glückwunsch")
is.ASCII("Congratulations") is.ASCII("Herzlichen Glückwunsch")
Shiny app for the association coefficients between two categorical variables. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_asso(...)
men_asso(...)
... |
one or more data sets |
nothing
if (interactive()) men_asso() if (interactive()) men_asso(HairEyeColor, Titanic)
if (interactive()) men_asso() if (interactive()) men_asso(HairEyeColor, Titanic)
Visualization of the probability mass and the cumulative distribution function of a binomial distribution.
men_bin(size = 10, prob = 0.5)
men_bin(size = 10, prob = 0.5)
size |
integer: number of trials (zero or more) |
prob |
numeric: probability of success on each trial |
nothing
if (interactive()) men_bin() if (interactive()) men_bin(20, 0.25)
if (interactive()) men_bin() if (interactive()) men_bin(20, 0.25)
Shiny app for a confidence interval for the mean. The data used is considered as a population from which random samples can be drawn. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_ci1(...)
men_ci1(...)
... |
one or more data sets |
nothing
if (interactive()) men_ci1() if (interactive()) men_ci1(stackloss)
if (interactive()) men_ci1() if (interactive()) men_ci1(stackloss)
Shiny app for a confidence interval for the difference of two means. The data used is considered as a population from which random samples can be drawn. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_ci2(...)
men_ci2(...)
... |
one or more data sets |
nothing
if (interactive()) men_ci2() if (interactive()) men_ci2(CO2)
if (interactive()) men_ci2() if (interactive()) men_ci2(CO2)
Shiny app for a length of a confidence interval for the mean.
men_cilen()
men_cilen()
nothing
if (interactive()) men_cilen()
if (interactive()) men_cilen()
Shiny app for a confidence interval for the proportion. The data used is considered as a population from which random samples can be drawn. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_cipi(...)
men_cipi(...)
... |
one or more data sets |
nothing
if (interactive()) men_cipi() if (interactive()) men_cipi(Titanic)
if (interactive()) men_cipi() if (interactive()) men_cipi(Titanic)
Shiny app for a confidence interval for the variance. The data used is considered as a population from which random samples can be drawn. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_cisig(...)
men_cisig(...)
... |
one or more data sets |
nothing
if (interactive()) men_cisig() if (interactive()) men_cisig(stackloss)
if (interactive()) men_cisig() if (interactive()) men_cisig(stackloss)
Shiny app for the correlation coefficients between two numeric variables. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_corr(...)
men_corr(...)
... |
one or more data sets |
nothing
if (interactive()) men_corr() if (interactive()) men_corr(iris)
if (interactive()) men_corr() if (interactive()) men_corr(iris)
Shiny app for detecting if a die is fair or unfair.
men_die()
men_die()
nothing
if (interactive()) men_die()
if (interactive()) men_die()
Shiny app for visualizing a univariate numeric variable as dotplot including univariate parameters. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_dot(...)
men_dot(...)
... |
one or more data sets |
nothing
if (interactive()) men_dot() if (interactive()) men_dot(iris)
if (interactive()) men_dot() if (interactive()) men_dot(iris)
Visualization of the density and the cumulative distribution function of a exponential distribution.
men_exp(rate = 1)
men_exp(rate = 1)
rate |
numeric: rate |
nothing
if (interactive()) men_exp() if (interactive()) men_exp(3)
if (interactive()) men_exp() if (interactive()) men_exp(3)
Shiny app for the Monty Hall problem:
men_hall(pointdoor = 1, afteropen = 1)
men_hall(pointdoor = 1, afteropen = 1)
pointdoor |
integer: to which door to point (default: |
afteropen |
integer: play strategy 1=keep door, 2=change door (default: |
Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?
nothing
if (interactive()) men_hall() if (interactive()) men_hall(4, 2)
if (interactive()) men_hall() if (interactive()) men_hall(4, 2)
Shiny app for visualizing a univariate numeric variable as histögram. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory. #'
men_hist(...)
men_hist(...)
... |
one or more data sets |
nothing
if (interactive()) men_hist() if (interactive()) men_hist(iris)
if (interactive()) men_hist() if (interactive()) men_hist(iris)
Visualization of the probability mass and the cumulative distribution function of a hypergeometric distribution.
men_hyp(N = 60, M = 30, n = 20)
men_hyp(N = 60, M = 30, n = 20)
N |
integer: the number of black and white balls in the urn |
M |
integer: the number of white balls in the urn |
n |
integer: the number of balls drawn from the urn |
nothing
if (interactive()) men_hyp() if (interactive()) men_hyp(50, 25, 10)
if (interactive()) men_hyp() if (interactive()) men_hyp(50, 25, 10)
Visualization of the density and the cumulative distribution function of a normal distribution.
men_norm(mean = 0, sd2 = 1)
men_norm(mean = 0, sd2 = 1)
mean |
numeric: mean |
sd2 |
numeric: variance |
nothing
if (interactive()) men_norm() if (interactive()) men_norm(1, 0.5)
if (interactive()) men_norm() if (interactive()) men_norm(1, 0.5)
Shiny app for the distribution of sample parameters. The data used is considered as a population from which random samples can be drawn. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_parn(...)
men_parn(...)
... |
one or more data sets |
nothing
if (interactive()) men_parn() if (interactive()) men_parn(iris)
if (interactive()) men_parn() if (interactive()) men_parn(iris)
men_poi Visualization of the probability mass and the cumulative distribution function of a Poisson distribution.
men_poi(lambda = 5)
men_poi(lambda = 5)
lambda |
numeric: (non-negative) mean |
nothing
if (interactive()) men_poi() if (interactive()) men_poi(3)
if (interactive()) men_poi() if (interactive()) men_poi(3)
Shiny app for the rank correlation coefficients between two ordered variables. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_rank(...)
men_rank(...)
... |
one or more data sets |
nothing
if (interactive()) men_rank() if (interactive()) { data("plantTraits", package="cluster") men_rank(plantTraits) }
if (interactive()) men_rank() if (interactive()) { data("plantTraits", package="cluster") men_rank(plantTraits) }
Shiny app for a simple linear regression. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_regr(...)
men_regr(...)
... |
one or more data sets |
nothing
if (interactive()) men_regr() if (interactive()) men_regr(stackloss)
if (interactive()) men_regr() if (interactive()) men_regr(stackloss)
Shiny app for frequency tables for two categorical variables. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_tab(...)
men_tab(...)
... |
one or more data sets |
nothing
if (interactive()) men_tab() if (interactive()) men_tab(HairEyeColor, Titanic)
if (interactive()) men_tab() if (interactive()) men_tab(HairEyeColor, Titanic)
Shiny app for a test for the true mean. The data used is considered as a population from which random samples can be drawn. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_terr(...)
men_terr(...)
... |
one or more data sets |
nothing
if (interactive()) men_terr() if (interactive()) men_terr(iris)
if (interactive()) men_terr() if (interactive()) men_terr(iris)
Shiny app for classical time series analysis If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_time(...)
men_time(...)
... |
one or more time series |
nothing
if (interactive()) men_time() if (interactive()) men_time(co2)
if (interactive()) men_time() if (interactive()) men_time(co2)
Shiny app for a test for the true mean. The data used is considered as a population from which random samples can be drawn. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_tmu1(...)
men_tmu1(...)
... |
one or more data sets |
nothing
if (interactive()) men_tmu1() if (interactive()) men_tmu1(iris)
if (interactive()) men_tmu1() if (interactive()) men_tmu1(iris)
Shiny app for a test on difference of two true means. The data used is considered as a population from which random samples can be drawn. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_tmu2(...)
men_tmu2(...)
... |
one or more data sets |
nothing
if (interactive()) men_tmu2() if (interactive()) men_tmu2(CO2)
if (interactive()) men_tmu2() if (interactive()) men_tmu2(CO2)
Shiny app for test on the proportion. The data used is considered as a population from which random samples can be drawn. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_tprop(...)
men_tprop(...)
... |
one or more data sets |
nothing
if (interactive()) men_tprop() if (interactive()) men_tprop(Titanic)
if (interactive()) men_tprop() if (interactive()) men_tprop(Titanic)
Shiny app for visualizing the univariate numeric variable, e.g. boxplot, stripchart, histogram, and cumulative distribution function. If no data are given then the default data from the book will be used. Otherwise the data will be stored as RDS file in a temporary directory.
men_vis(...)
men_vis(...)
... |
one or more data sets |
nothing
if (interactive()) men_vis() if (interactive()) men_vis(iris)
if (interactive()) men_vis() if (interactive()) men_vis(iris)
Returns the parameters for a variable. If type="numeric"
then descriptive measures will be returned.
Otherwise absolute and relative frequencies will be returned. For using a subset of observation set index
.
mmstat.attrVar(var, type, index = NULL)
mmstat.attrVar(var, type, index = NULL)
var |
vector: values of a mmstat variable |
type |
character: type of values, allowed are |
index |
integer: observation numbers to use for computation, default is to use all observations |
descriptive measures
# make sure that no other data sets are loaded mmstat.set(datasets=NULL) mmstat.getDataNames(mmstat.rds("CARS")) # summary of first numeric variable in first data set in mmstat var <- mmstat.getVar(1, 1, 'numeric') mmstat.attrVar(var, "numeric") # summary of first factor variable in first data set in mmstat var <- mmstat.getVar(1, 1, 'factor') mmstat.attrVar(var, 'factor')
# make sure that no other data sets are loaded mmstat.set(datasets=NULL) mmstat.getDataNames(mmstat.rds("CARS")) # summary of first numeric variable in first data set in mmstat var <- mmstat.getVar(1, 1, 'numeric') mmstat.attrVar(var, "numeric") # summary of first factor variable in first data set in mmstat var <- mmstat.getVar(1, 1, 'factor') mmstat.attrVar(var, 'factor')
Based on range
the position of the labels are determined and the axis is plotted.
mmstat.axis(side, range, at, labels, ...)
mmstat.axis(side, range, at, labels, ...)
side |
an integer specifying which side of the plot the axis is to be drawn on. The axis is placed as follows: 1=below, 2=left, 3=above and 4=right. |
range |
range: a data range |
at |
the points at which tick-marks are to be drawn. Non-finite
(infinite, |
labels |
this can either be a logical value specifying whether
(numerical) annotations are to be made at the tickmarks, or a
character or expression vector of labels to be placed at the
tickpoints. (Other objects are coerced by |
... |
further parameters to graphics::axis |
adds a axis to a plot
oldpar <- par(mfrow=c(1,2)) plot(iris[,1]) plot(iris[,1], axes=FALSE) mmstat.axis(2, iris[,1]) par(oldpar)
oldpar <- par(mfrow=c(1,2)) plot(iris[,1]) plot(iris[,1], axes=FALSE) mmstat.axis(2, iris[,1]) par(oldpar)
Based on range
the position of the labels are determined and the axis is plotted.
mmstat.baraxis(side, range, at, labels, ...)
mmstat.baraxis(side, range, at, labels, ...)
side |
an integer specifying which side of the plot the axis is to be drawn on. The axis is placed as follows: 1=below, 2=left, 3=above and 4=right. |
range |
range: a data range |
at |
the points at which tick-marks are to be drawn. Non-finite
(infinite, |
labels |
this can either be a logical value specifying whether
(numerical) annotations are to be made at the tickmarks, or a
character or expression vector of labels to be placed at the
tickpoints. (Other objects are coerced by |
... |
further parameters to graphics::axis |
adds a axis to a plot
oldpar <- par(mfrow=c(1,2)) x <- 0:15 px <- dbinom(x, 10, 0.5) plot(x, px, type="h") plot(x, px, type="h", axes=FALSE) mmstat.baraxis(1, range(x), at=x, labels=as.character(x)) par(oldpar)
oldpar <- par(mfrow=c(1,2)) x <- 0:15 px <- dbinom(x, 10, 0.5) plot(x, px, type="h") plot(x, px, type="h", axes=FALSE) mmstat.baraxis(1, range(x), at=x, labels=as.character(x)) par(oldpar)
Computes the number of the significant digits based on the smallest non-zero difference of the sorted data.
mmstat.dec(x, ord = NULL)
mmstat.dec(x, ord = NULL)
x |
numeric: data vector |
ord |
index: subset of the ordered data (default: |
The number of significant digits and (the subset of) the order of the data.
x <- rnorm(20) d <- mmstat.dec(x) # create strings so that they are unique (if they were) sprintf("%.*f", d$dec, x)
x <- rnorm(20) d <- mmstat.dec(x) # create strings so that they are unique (if they were) sprintf("%.*f", d$dec, x)
Returns the names of data sets and stores them in the internal environment. The name of the data set is base name without extension.
mmstat.getDataNames(...)
mmstat.getDataNames(...)
... |
character: names of the data sets. |
the names of the data sets
files <- mmstat.rds("HAIR.EYE.COLOR", "TITANIC") mmstat.getDataNames(files)
files <- mmstat.rds("HAIR.EYE.COLOR", "TITANIC") mmstat.getDataNames(files)
Reads data set(s) into the mmstat object.
mmstat.getDatasets(...)
mmstat.getDatasets(...)
... |
character: file name(s) of RDS data file(s) |
the names of the data set(s)
# not used, deprecated??
# not used, deprecated??
Returns the internal log message as HTML. In a Shiny app the log message are updated every 100 milliseconds
mmstat.getLog(session)
mmstat.getLog(session)
session |
session object |
HTML code
# will work only in A Shiny app if (interactive()) { require("shiny") ui <- fluidPage( titlePanel("getLog example"), sidebarLayout(sidebarPanel( actionButton("quit", "Quit")), mainPanel(textOutput("log")) ) ) # server <- function(input, output, session) { observeEvent(input$quit, { stopApp() }) output$log <- renderText({ mmstat.getLog(session) }) } # shinyApp(ui, server) }
# will work only in A Shiny app if (interactive()) { require("shiny") ui <- fluidPage( titlePanel("getLog example"), sidebarLayout(sidebarPanel( actionButton("quit", "Quit")), mainPanel(textOutput("log")) ) ) # server <- function(input, output, session) { observeEvent(input$quit, { stopApp() }) output$log <- renderText({ mmstat.getLog(session) }) } # shinyApp(ui, server) }
mmstat.getValues
returns a list with named elements. If the parameter is NULL
then a default value stored
local
will be used.
mmstat.getValue
returns a value. If the parameter is NULL
or NA
then def
will be returned
mmstat.getValues(local, ...) mmstat.getValue(val, def)
mmstat.getValues(local, ...) mmstat.getValue(val, def)
local |
list: default values for the named parameter |
... |
list of named parameters |
val |
value for a parameter |
def |
default value for a parameter |
a list of requested parameters
def <- list(a=3) mmstat.getValues(def, b=3, a=NULL) mmstat.getValue(NA, 5) mmstat.getValue(NULL, 5) mmstat.getValue(3, 5)
def <- list(a=3) mmstat.getValues(def, b=3, a=NULL) mmstat.getValue(NA, 5) mmstat.getValue(NULL, 5) mmstat.getValue(3, 5)
Returns the from a data set a variable from the given type.
mmstat.getVar( dataname = NULL, varname = NULL, vartype = NULL, na.action = stats::na.omit )
mmstat.getVar( dataname = NULL, varname = NULL, vartype = NULL, na.action = stats::na.omit )
dataname |
integer: number of data set |
varname |
integer: number of variable |
vartype |
character: variable type, one of |
na.action |
function: indicate what should happen when the data contain NAs (default: stats::na.omit) |
a variable of the given type
# make sure that no other data sets are loaded mmstat.set(datasets=NULL) mmstat.getDataNames(mmstat.rds("CARS")) # summary of first numeric variable in first data set in mmstat str(mmstat.getVar(1, 1, 'numeric')) # summary of first factor variable in first data set in mmstat str(mmstat.getVar(1, 1, 'factor'))
# make sure that no other data sets are loaded mmstat.set(datasets=NULL) mmstat.getDataNames(mmstat.rds("CARS")) # summary of first numeric variable in first data set in mmstat str(mmstat.getVar(1, 1, 'numeric')) # summary of first factor variable in first data set in mmstat str(mmstat.getVar(1, 1, 'factor'))
Returns all variable names of data set stored in the internal environment.
mmstat.getVariableNames(name)
mmstat.getVariableNames(name)
name |
character or numeric: name or index of data set |
vector of names
# Delete all stored data sets mmstat.set(datasets=NULL) # Load CAR data set into mmstat mmstat.getDataNames(mmstat.rds("CARS")) # Extract names of all variables mmstat.getVariableNames(1)
# Delete all stored data sets mmstat.set(datasets=NULL) # Load CAR data set into mmstat mmstat.getDataNames(mmstat.rds("CARS")) # Extract names of all variables mmstat.getVariableNames(1)
Returns the variable names of a specific type from a mmstat data set.
mmstat.getVarNames(dataname, vartype, which = NULL)
mmstat.getVarNames(dataname, vartype, which = NULL)
dataname |
character: name of data set |
vartype |
character: type of variable, either |
which |
integer: index number |
a vector or element of variable names which have the type vartype
# Load CAR data set into mmstat mmstat.getDataNames(mmstat.rds("CARS")) # Extract names of numeric variables mmstat.getVarNames(1, "numeric")
# Load CAR data set into mmstat mmstat.getDataNames(mmstat.rds("CARS")) # Extract names of numeric variables mmstat.getVarNames(1, "numeric")
Loads a PO file for a translation into the internal environment.
mmstat.lang(pof = NULL)
mmstat.lang(pof = NULL)
pof |
character: file name |
nothing
mmstat.lang()
mmstat.lang()
Writes a message into the internal log.
mmstat.log(txt)
mmstat.log(txt)
txt |
character: message to write |
nothing
mmstat.log("Test")
mmstat.log("Test")
Returns a math expression based on HTML special characters notation.
mmstat.math(txt)
mmstat.math(txt)
txt |
character: input text |
expression
mmstat.math(" &bar(X);~&N(mu[0], sigma^2/n); ") mmstat.math("&H[0];: &mu==mu[0]; vs. &H[1];: &mu!=mu[0]; ")
mmstat.math(" &bar(X);~&N(mu[0], sigma^2/n); ") mmstat.math("&H[0];: &mu==mu[0]; vs. &H[1];: &mu!=mu[0]; ")
Computes a new range from by a union of the two ranges.
mmstat.merge(range1, range2)
mmstat.merge(range1, range2)
range1 |
range: first range |
range2 |
range: second range |
new range
mmstat.merge(c(0,1), c(0.5, 2)) # returns c(0, 2)
mmstat.merge(c(0,1), c(0.5, 2)) # returns c(0, 2)
Plots the test regions in a plot
mmstat.plotTestRegions( crit, xlim, ylim, cex, close = FALSE, col = "black", label = NULL, pos = 1 )
mmstat.plotTestRegions( crit, xlim, ylim, cex, close = FALSE, col = "black", label = NULL, pos = 1 )
crit |
numeric(2): critical value(s) |
xlim |
numeric(2): the x limits of the plot |
ylim |
numeric(2): the y limits of the plot |
cex |
numeric: amount by which plotting text should be magnified relative to the default |
close |
logical: should the region box be closed by vertical lines (default: |
col |
color: pecification for the default plotting color (default: |
label |
unused |
pos |
unused |
adds test regions to a plot
x <- (-30:30)/10 px <- dnorm(x) plot(x, px, type="l", ylim=c(-0.25, max(px)), xlim=range(x)) mmstat.plotTestRegions(crit=c(-1.96, +1.96), xlim=range(x), ylim=c(-0.2, -0.1), cex=1)
x <- (-30:30)/10 px <- dnorm(x) plot(x, px, type="l", ylim=c(-0.25, max(px)), xlim=range(x)) mmstat.plotTestRegions(crit=c(-1.96, +1.96), xlim=range(x), ylim=c(-0.2, -0.1), cex=1)
Returns a linear interpolation based on minmax
.
mmstat.pos(minmax, pos)
mmstat.pos(minmax, pos)
minmax |
numeric(2): range to interpolate between |
pos |
numeric: proportion(s) to interpolate, usually between zero and one |
interpolated values
mmstat.pos(c(0,360), 0.5)
mmstat.pos(c(0,360), 0.5)
Computes a range from several R objects by union.
mmstat.range(...)
mmstat.range(...)
... |
R objects |
range
mmstat.range(-5:5, 0:10) # returns c(-5, 10)
mmstat.range(-5:5, 0:10) # returns c(-5, 10)
Returns the full file names of all or specific data set that come with the package.
mmstat.rds(...)
mmstat.rds(...)
... |
names of data sets |
full file names
mmstat.rds() # return all RDS file that come with the package mmstat.rds("HAIR.EYE.COLOR", "TITANIC") # location of specific data sets
mmstat.rds() # return all RDS file that come with the package mmstat.rds("HAIR.EYE.COLOR", "TITANIC") # location of specific data sets
Rounds down.
mmstat.round.down(x, digits = 0)
mmstat.round.down(x, digits = 0)
x |
numeric: values for rounding |
digits |
numeric: digits for rounding (default: |
down rounded values
x <- runif(5) cbind(x, mmstat.round.down(x, 1))
x <- runif(5) cbind(x, mmstat.round.down(x, 1))
Rounds up.
mmstat.round.up(x, digits = 0)
mmstat.round.up(x, digits = 0)
x |
numeric: values for rounding |
digits |
numeric: digits for rounding (default: |
uprounded values
x <- runif(5) cbind(x, mmstat.round.up(x, 1))
x <- runif(5) cbind(x, mmstat.round.up(x, 1))
mmstat.set
sets one (or more) parameter to the internal environment. mmstat.get
return one or more parameters from the internal environment.
mmstat.set(...) mmstat.get(...)
mmstat.set(...) mmstat.get(...)
... |
named parameters with values or names |
nothing
mmstat.set(debug=0) mmstat.get("debug") mmstat.get("debug", "shiny") # returns a list
mmstat.set(debug=0) mmstat.get("debug") mmstat.get("debug", "shiny") # returns a list
A modified sliderInput
for mmstat
which supports user defined tick marks.
mmstat.sliderInput(...)
mmstat.sliderInput(...)
... |
parameters for shiny::sliderInput |
the HTML output
ticks <- c(80, 85, 90, 95, 98, 99, 99.5, 99.9) mmstat.sliderInput("id", "label", min=1, max=length(ticks), value=3, step=1, ticks=ticks)
ticks <- c(80, 85, 90, 95, 98, 99, 99.5, 99.9) mmstat.sliderInput("id", "label", min=1, max=length(ticks), value=3, step=1, ticks=ticks)
Returns tick marks for a log based scale between nmin
and nin
.
mmstat.ticks(nin, nmin = 3, tin = 11)
mmstat.ticks(nin, nmin = 3, tin = 11)
nin |
integer: maximun of scale |
nmin |
integer: minimun of scale |
tin |
integer: number of desired tick marks |
vector of tick marks
mmstat.ticks(506)
mmstat.ticks(506)
Calls the underlying Shiny UI element (selectInput
, ...).
mmstat.ui.call(inputId, ...)
mmstat.ui.call(inputId, ...)
inputId |
character: the input slot called |
... |
further parameters given to the call |
whatever the call to the underlying Shiny UI element returns
mmstat.ui.elem(inputId="alpha", type="significance") mmstat.ui.call("alpha")
mmstat.ui.elem(inputId="alpha", type="significance") mmstat.ui.call("alpha")
Adds a new UI element to the app interface. The following types from Shiny are allowed:
submitButton
, and
Additionally some standard statistical UI elements are supported (links go to the Shiny element used):
variableN
, and
Partially these elements have default settings which can be overwritten.
mmstat.ui.elem(inputId, type, ...)
mmstat.ui.elem(inputId, type, ...)
inputId |
character: input slot that will be used to access the value |
type |
character: element type |
... |
further named parameter to Shiny UI elements |
nothing
mmstat.ui.elem(inputId="alpha", type="significance")
mmstat.ui.elem(inputId="alpha", type="significance")
Call for a update of an underlying Shiny UI element (selectInput
, ...).
mmstat.ui.update(inputId, ...)
mmstat.ui.update(inputId, ...)
inputId |
character: the input slot called |
... |
further parameters given to the call |
whatever the update to the underlying Shiny UI element returns
mmstat.ui.elem(inputId="alpha", type="significance") mmstat.ui.call("alpha")
mmstat.ui.elem(inputId="alpha", type="significance") mmstat.ui.call("alpha")
Writes a warning text into the log object in the internal mmstat object.
mmstat.warn(cond, txt)
mmstat.warn(cond, txt)
cond |
logical: condition to test |
txt |
character: text to write if |
nothing
mmstat.warn(TRUE, "just a true seen")
mmstat.warn(TRUE, "just a true seen")
Resets the par if necessary.
resetpar(oldpar)
resetpar(oldpar)
oldpar |
graphical parameters |
nothing
par("mar") oldpar <- par(no.readonly = TRUE) par(mar = c(0,0,0,0)) par("mar") resetpar(oldpar) par("mar")
par("mar") oldpar <- par(no.readonly = TRUE) par(mar = c(0,0,0,0)) par("mar") resetpar(oldpar) par("mar")
A equivalent to stopifnot
: if cond
is TRUE
then a error is thrown.
stopif(cond, txt)
stopif(cond, txt)
cond |
logical: condition to test |
txt |
character: error message |
nothing
if (interactive()) stopif(1+1==2, "1+1 can not be 2, this is fake science!")
if (interactive()) stopif(1+1==2, "1+1 can not be 2, this is fake science!")
Converts a table to a full data frame.
table2dataframe(tab, ...)
table2dataframe(tab, ...)
tab |
table: contingency table |
... |
further parameters given to base::as.data.frame.table |
a data frame with sum(tab)
rows and length(dim(tab))
cols
table2dataframe(Titanic)
table2dataframe(Titanic)
Returns a HTMl representation of a matrix and optionally shows the result in the browser.
If you decide to view the result in a browser then the HTML will be written to a temporary file and
utils::browseURL()
called
## S3 method for class 'html_matrix' toHTML(x, browser = FALSE, ...) ## S3 method for class 'table' toHTML(x, browser = FALSE, ...) ## S3 method for class 'matrix' toHTML(x, browser = FALSE, ...)
## S3 method for class 'html_matrix' toHTML(x, browser = FALSE, ...) ## S3 method for class 'table' toHTML(x, browser = FALSE, ...) ## S3 method for class 'matrix' toHTML(x, browser = FALSE, ...)
x |
html_matrix object |
browser |
logical: show HTML in a browser (default: |
... |
further parameters to |
html_matrix object
library("tools") m <- matrix(1:12, ncol=4) hm <- html_matrix(m) html <- toHTML(hm, browser=interactive())
library("tools") m <- matrix(1:12, ncol=4) hm <- html_matrix(m) html <- toHTML(hm, browser=interactive())
Saves one or more data sets in RDS format to a temporary directory (tmpdir()
).
Data sets must have the class ts
or something that can be converted
to a data frame, e.g. matrix
, table
, etc.
toRDS(...)
toRDS(...)
... |
data sets to save |
returns the name of the created files
toRDS(Titanic) # saves to tempdir/Titanic.rds
toRDS(Titanic) # saves to tempdir/Titanic.rds
Uppercases the first character in txt
.
ucfirst(txt)
ucfirst(txt)
txt |
character: |
character
ucfirst("hello world")
ucfirst("hello world")
zebra
zebra(x, col = c("#FFFFFF", "#CCCCCC"), byrow = TRUE)
zebra(x, col = c("#FFFFFF", "#CCCCCC"), byrow = TRUE)
x |
html_matrix object |
col |
a vector of colors to zebra with (default: |
byrow |
logical: zebra by row or by column (default: |
html_matrix object
library("magrittr") library("tools") m <- matrix(1:12, ncol=4) hm <- html_matrix(m) %>% zebra() html <- toHTML(hm, browser=interactive())
library("magrittr") library("tools") m <- matrix(1:12, ncol=4) hm <- html_matrix(m) %>% zebra() html <- toHTML(hm, browser=interactive())
Checks if all necessary packages are installed.
zzz()
zzz()
a logical vector which of the required packages are available
zzz()
zzz()