R – Funktionen
_Statistik
Im Folgenden werden die (meisten) Funktionen aufgelistet, die wir in den Übungen verwendet haben. Die Reihenfolge ist einigermaßen chronologisch.
read.csv2()
- Reads a file in table format and creates a data frame from it, with cases corresponding to lines and variables to fields in the file.
read.csv2(file, header = TRUE, sep = ";", quote = "\"",
dec = ",", fill = TRUE, comment.char = "", …)
table()
- uses the cross-classifying factors to build a contingency table of the counts at each combination of factor levels.
table(…,
exclude = if (useNA == "no") c(NA, NaN),
useNA = c("no", "ifany", "always"),
dnn = list.names(…), deparse.level = 1)
replace()
- replaces the values in x with indices given in list by those given in values. If necessary, the values in values are recycled.
replace(x, list, values)
hist()
- The generic function hist computes a histogram of the given data values. If plot = TRUE, the resulting object of class “histogram” is plotted by plot.histogram, before it is returned.
hist(x, breaks = "Sturges",
freq = NULL, probability = !freq,
include.lowest = TRUE, right = TRUE,
density = NULL, angle = 45, col = NULL, border = NULL,
main = paste("Histogram of" , xname),
xlim = range(breaks), ylim = NULL,
xlab = xname, ylab,
axes = TRUE, plot = TRUE, labels = FALSE,
nclass = NULL, warn.unused = TRUE, …)
mean()
- Generic function for the (trimmed) arithmetic mean.
mean(x, trim = 0, na.rm = FALSE, …)
sd()
- This function computes the standard deviation of the values in x. If na.rm is TRUE then missing values are removed before computation proceeds.
sd(x, na.rm = FALSE)
c()
- This is a generic function which combines its arguments. The default method combines its arguments to form a vector. All arguments are coerced to a common type which is the type of the returned value, and all attributes except names are removed.
c(…, recursive = FALSE, use.names = TRUE)
sum()
- sum returns the sum of all the values present in its arguments.
sum(…, na.rm = FALSE)
scale()
- scale(x, center = TRUE, scale = TRUE)
scale is generic function whose default method centers and/or scales the columns of a numeric matrix.
dnorm(), pnorm(), qnorm(), rnorm()
- Density, distribution function, quantile function and random generation for the normal distribution with mean equal to mean and standard deviation equal to sd.
dnorm(x, mean = 0, sd = 1, log = FALSE)
pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
qnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
rnorm(n, mean = 0, sd = 1)
dt(), pt(), qt(), rt()
- Density, distribution function, quantile function and random generation for the t distribution with df degrees of freedom (and optional non-centrality parameter ncp).
dt(x, df, ncp, log = FALSE)
pt(q, df, ncp, lower.tail = TRUE, log.p = FALSE)
qt(p, df, ncp, lower.tail = TRUE, log.p = FALSE)
rt(n, df, ncp)
set.seed()
- Seeding Random Variate Generators
set.seed(seed, kind = NULL, normal.kind = NULL)
round()
- rounds the values in its first argument to the specified number of decimal places (default 0).
round(x, digits = 0)
length()
- Get or set the length of vectors (including lists) and factors, and of any other R object for which a method has been defined.
length(x)
sqrt()
- Computes the square root of the specified float value.
sqrt(x)
t.test()
- Performs one and two sample t-tests on vectors of data.
t.test(x, y = NULL,
alternative = c("two.sided", "less", "greater"),
mu = 0, paired = FALSE, var.equal = FALSE,
conf.level = 0.95, …)
t.test(formula, data, subset, na.action, …)
chisq.test
- chisq.test performs chi-squared contingency table tests and goodness-of-fit tests.
chisq.test(x, y = NULL, correct = TRUE,
p = rep(1/length(x), length(x)), rescale.p = FALSE,
simulate.p.value = FALSE, B = 2000)
cramerV
- Calculates Cramer’s V for a table of nominal variables
cramerV(
x,
...)
cor
- cor computes the correlation of x and y if these are vectors. If x and y are matrices then the correlations between the columns of x and the columns of y are computed.
cor(x, y = NULL, use = "everything",
method = c("pearson", "kendall", "spearman"))
cor.test
- Test for association between paired samples, using one of Pearson’s product moment correlation coefficient, Kendall’s \(\tau\) or Spearman’s \(\rho\).
cor.test(x, y,
alternative = c("two.sided", "less", "greater"),
method = c("pearson", "kendall", "spearman"),
exact = NULL, conf.level = 0.95, continuity = FALSE, …)
lm
- lm is used to fit linear models. It can be used to carry out regression, single stratum analysis of variance and analysis of covariance (although aov may provide a more convenient interface for these).
lm(formula, data, subset, weights, na.action,
method = "qr", model = TRUE, x = FALSE, y = FALSE, qr = TRUE,
singular.ok = TRUE, contrasts = NULL, offset, …)
Hilfsfunktionen: plot()
, abline()
, summary()
anova
- Compute analysis of variance (or deviance) tables for one or more fitted model objects.
anova(object, …)
aov
- Fit an Analysis of Variance Model -
aov(formula, data = NULL, projections = FALSE, qr = TRUE,
contrasts = NULL, …)