add_data: add_data

View source: R/add_data.R

add_dataR Documentation

add_data

Description

Adds data values to a given data vector x.

Usage

add_data(x, box, n = c(0, 1), range = c(0, 1))

Arguments

x

numeric: data vector

box

character or numeric: basic box used

n

numeric: number of data values on the left, the right or both sides of x (default: c(0,1))

range

numeric: determines the range where the additional data values will be drawn from (default: c(0,1))

Details

Based on the data x or the range(box) a box is computed. The length aof the box gives the multiplier for the range. Then a left and right interval from which the additional values are drawn uniformly is computed: [left box value-range[2]*box length; left box value-range[1]*box length] (left interval) and [right box value+range[1]*box length; right box value+range[2]*box length] (right interval).

For box can be used also "boxplot" and quantile(x, c(0.25, 0.75), na.rm=TRUE) is used or "range" and range(x, na.rm=TRUE) is used.

n can be a single number which will add n data values at the right side of x. If n is a vector of length two then n[1] data values will be added at the left side of x and n[2] data values will be added at the right side of x.

Value

a data vectors with new values

Examples

x <- rnorm(8)
# add one value to the right
add_data(x, "box", range=1.5)
add_data(x, "range", range=0.1)
add_data(x, "box", range=c(1.5, 3))
# add two values to the right
add_data(x, "range", n=2, range=0.1)
# add two values to the left and three to the right
add_data(x, "range", n=c(2,3), range=0.1)

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.