Learn R Programming

qrmtools (version 0.0-15)

NA_plot: Graphical Tool for Visualizing NAs in a Data Set

Description

Plot NAs in a data set.

Usage

NA_plot(x, col = c("black", "white"), xlab = "Time", ylab = "Component",
        text = "Black: NA; White: Available data",
        side = 4, line = 1, adj = 0, ...)

Value

invisible().

Arguments

x

matrix (ideally an xts object).

col

bivariate vector containing the colors for missing and available data, respectively.

xlab

x-axis label.

ylab

y-axis label.

text

see mtext(). The text = "", it is omitted.

side

see mtext().

line

see mtext().

adj

see mtext().

...

additional arguments passed to the underlying image().

Author

Marius Hofert

Details

Indicate NAs in a data set.

Examples

Run this code
## Generate data
n <- 1000 # sample size
d <- 100 # dimension
set.seed(271) # set seed
x <- matrix(runif(n*d), ncol = d) # generate data

## Assign missing data
k <- ceiling(d/4) # fraction of columns with some NAs
j <- sample(1:d, size = k) # columns j with NAs
i <- sample(1:n, size = k) # 1:i will be NA in each column j
X <- x
for(k. in seq_len(k)) X[1:i[k.], j[k.]] <- NA # put in NAs

## Plot NAs
NA_plot(X) # indicate NAs

Run the code above in your browser using DataLab