diff --git a/NAMESPACE b/NAMESPACE
index b8ed91efa77e50253361407d52624b2f79da78f8..8f9666392780cee10695722d241df65923d55f65 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,5 +1,10 @@
# Generated by roxygen2: do not edit by hand
export("%>%")
+export(calc_vif)
+export(explore_na)
+export(impute)
+export(test_tac)
export(trafficlight)
+import(graphics)
importFrom(magrittr,"%>%")
diff --git a/R/calc_vif.R b/R/calc_vif.R
index 05f4cea103c21746fe3a741fb8f263e404de6fcd..0aeb589d30dec8c68284cbe1f9119d1823a668bf 100644
--- a/R/calc_vif.R
+++ b/R/calc_vif.R
@@ -26,9 +26,9 @@ calc_vif <- function(x) {
for (v in 1:ncol(x)) {
v.name <- colnames(x)[v]
other.v.names <- colnames(x)[-v]
- mod.formula <- as.formula(paste(v.name, "~", paste(other.v.names, collapse = "+")))
- mod <- lm(mod.formula, data = x)
- R2 <- summary(mod) $ r.squared
+ mod.formula <- stats::as.formula(paste(v.name, "~", paste(other.v.names, collapse = "+")))
+ mod <- stats::lm(mod.formula, data = x)
+ R2 <- summary(mod)$r.squared
result[v, "Rsquared"] <- R2
result[v, "Tolerance"] <- 1 - R2
result[v, "VIF"] <- 1 / (1 - R2)
diff --git a/R/explore_na.R b/R/explore_na.R
index 75dcc9f504dcaf10955b6f38c29af63031707716..570bf878ddd233eb65d70e6520c5f5fc7c3fbf08 100644
--- a/R/explore_na.R
+++ b/R/explore_na.R
@@ -18,6 +18,7 @@
#' @param respect logical; this argument controls whether a unit column-width is the
#' same physical measurement on the device as a unit row-height (default is TRUE).
#'
+#' @import graphics
#' @export
#' @author Saskia A. Otto
#' @examples
@@ -26,10 +27,10 @@
#' colnames(mat) <- paste0("variable", 1:10)
#' explore_na(x = mat, time = 1981:2000)
#' colnames(mat) <- LETTERS[1:10]
-#' explore_na(x = mat, time = 1981:2000, madj_y = -1.5, hadj_y = 2, respect = FALSE)
+#' explore_na(x = mat, time = 1981:2000, madj_y = -2.5, hadj_y = 2, respect = FALSE)
explore_na <- function(x, time = NULL, cex_x = 1, cex_y = 1,
- madj_y = 0, hadj_y = 1, respect = TRUE,...){
+ madj_y = 0, hadj_y = 1, respect = TRUE){
if(!is.null(time)) {
rownames(x) <- time
@@ -48,7 +49,7 @@ explore_na <- function(x, time = NULL, cex_x = 1, cex_y = 1,
x <- x[reverse,]
# Data Map
- layout(matrix(c(1,1,2,1,1,2,3,3,4), ncol=3, byrow = TRUE), widths = c(2,2,1.5),
+ layout(matrix(c(1,1,2,1,1,2,3,3,4), ncol=3, byrow = TRUE), widths = c(2.5,2,1.5),
heights = c(2,1,1.5), respect = respect)
# graphics::layout(matrix(c(1,1,1,1), ncol = 2), widths = c(3.5,3.5), heights = c(2,2),
# respect = respect)
@@ -68,7 +69,7 @@ explore_na <- function(x, time = NULL, cex_x = 1, cex_y = 1,
title(xlab="Number of years", line=2, cex.lab=1.2)
#barplot stations
- par(mar = c(4, 5+madj_y, 1.5, .5))
+ par(mar = c(4, 7+madj_y, 1.5, .5))
barplot(apply(x>0, 2, sum), ylab = "",
las = 2, cex.axis = cex_y, space = 0, col = "#db7170", xaxs = "i")
title(ylab="Number of variables", line=2.5, cex.lab=1.2)
diff --git a/man/calc_vif.Rd b/man/calc_vif.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..99c504d82e868fd57431e98d6d1f2afe8ffec81f
--- /dev/null
+++ b/man/calc_vif.Rd
@@ -0,0 +1,29 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/calc_vif.R
+\name{calc_vif}
+\alias{calc_vif}
+\title{Calculate the variance inflation factors}
+\usage{
+calc_vif(x)
+}
+\arguments{
+\item{x}{matrix or data frame containing only numerical variables.}
+}
+\value{
+The function returns a matrix with 3 columns:
+\describe{
+ \item{\code{Rsquared}}{}
+ \item{\code{Tolerance}}{}
+ \item{\code{VIF}}{}
+ }
+}
+\description{
+Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
+eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
+voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
+clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
+}
+\examples{
+x <- data.frame(a = 1:20, b = 1:20*2 + rnorm(20) )
+calc_vif(x)
+}
diff --git a/man/explore_na.Rd b/man/explore_na.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..6c395de99d547efc6bb5f5d7106f42bfb47c46f3
--- /dev/null
+++ b/man/explore_na.Rd
@@ -0,0 +1,52 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/explore_na.R
+\name{explore_na}
+\alias{explore_na}
+\title{Create multiple plots to explore gaps in the time series}
+\usage{
+explore_na(
+ x,
+ time = NULL,
+ cex_x = 1,
+ cex_y = 1,
+ madj_y = 0,
+ hadj_y = 1,
+ respect = TRUE
+)
+}
+\arguments{
+\item{x}{matrix or data frame containing time series of multiple variables.}
+
+\item{time}{vector of time units that will be used for the x ax}
+
+\item{cex_x}{double; the magnification to be used for the x labels relative to the
+current setting of cex.}
+
+\item{cex_y}{double; the magnification to be used for the y labels relative to the
+current setting of cex.}
+
+\item{madj_y}{double; adjustment of left margin relative to the
+current setting for longer or short variable names in the image plot and right barplot.}
+
+\item{hadj_y}{double; horizontal adjustment of the y labels in the image plot.}
+
+\item{respect}{logical; this argument controls whether a unit column-width is the
+same physical measurement on the device as a unit row-height (default is TRUE).}
+}
+\description{
+This function creates an image plot where available values for the different variables and years
+are indicated in gray and missing values in white. At the right side and bottom, two barplots
+are added showing the frequency of available variables per year and the available years per
+variable.
+}
+\examples{
+mat <- matrix(1:200, ncol = 10)
+mat[sample(1:200, sample(10:80, 1))] <- NA
+colnames(mat) <- paste0("variable", 1:10)
+explore_na(x = mat, time = 1981:2000)
+colnames(mat) <- LETTERS[1:10]
+explore_na(x = mat, time = 1981:2000, madj_y = -2.5, hadj_y = 2, respect = FALSE)
+}
+\author{
+Saskia A. Otto
+}
diff --git a/man/impute.Rd b/man/impute.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..ed98d9b91e9e7b4276bff708b2ed400b693b6e79
--- /dev/null
+++ b/man/impute.Rd
@@ -0,0 +1,30 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/impute.R
+\name{impute}
+\alias{impute}
+\title{Imputation of missing values by local mean substitution}
+\usage{
+impute(x, n = 2)
+}
+\arguments{
+\item{x}{numeric vector containing NAs.}
+
+\item{n}{integer; the number of previous and following values to be included in the mean.
+The default is 2 so the mean is based on a 5yr-period (including the year of the missing
+value).}
+}
+\value{
+The function returns the same numeric input vector, but with replaced missing values.
+}
+\description{
+The function substitutes missing values in time series with a mean of the \emph{n} previous and following years
+(or less depending on the position of NAs, whether it is at the beginning or end of the time series, and
+the presence of further NAs in the selected time period).
+}
+\examples{
+x <- c(NA, 1, 4, 2, 5, NA, 9, NA, 12, 11, NA)
+impute(x)
+}
+\author{
+Saskia A. Otto
+}
diff --git a/man/test_tac.Rd b/man/test_tac.Rd
new file mode 100644
index 0000000000000000000000000000000000000000..eedc42cff45d2ada6443571d01825b8ec4b968f3
--- /dev/null
+++ b/man/test_tac.Rd
@@ -0,0 +1,28 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/test_tac.R
+\name{test_tac}
+\alias{test_tac}
+\title{Compute (partial) autocorrelation functions and test for significance}
+\usage{
+test_tac(x)
+}
+\arguments{
+\item{x}{numeric; an evenly spaced time vector which should be tested for temporal
+autocorrelation. Temporal gaps should be included as NAs.}
+}
+\value{
+The function returns a list with 2 components:
+\describe{
+ \item{\code{tac}}{TRUE if any lag in the (partial) autocorrelation functions
+ is significantly correlated (if correlation value > 0.4), else FALSE.}
+ \item{\code{max_lag}}{The maximal lag that is correlated.}
+ }
+}
+\description{
+Compute (partial) autocorrelation functions and test for significance
+}
+\examples{
+test_tac(x = 1:20)
+test_tac(x = rnorm(20))
+
+}
diff --git a/man/trafficlight.Rd b/man/trafficlight.Rd
index 7c1be8e46954073f060d85c1c3da954691a49af8..29d9f16cd960d5446ebb66def456d5be55e2d73e 100644
--- a/man/trafficlight.Rd
+++ b/man/trafficlight.Rd
@@ -63,7 +63,7 @@ numeric vector of probabilities with values in [0,1]. (Values up to
\item{quantile_type}{an integer between 1 and 9 selecting one of the nine quantile
algorithms detailed below to be used. Default is 7 (see also \code{\link{quantile}}).}
-\item{intervals}{logical; number of evenly-spaced intervals. Default is 5.}
+\item{intervals}{logical; number of evenly spaced intervals. Default is 5.}
\item{cols}{a character vector with colors for each quantile or interval.}