rdatarepl: Random replacements of data.

View source: R/rdatarepl.R

rdatareplR Documentation

Random replacements of data.

Description

Replaces data in the original data matrix using a specified replacement matrix.

Usage

rdatarepl(Dx, RM, printfp = TRUE)

Arguments

Dx

Data frame or matrix to be replaced.

RM

Replacement matrix.

printfp

Logical, if TRUE (the default), it prints the percentage of data replaced.

Details

Replacement matrices can be obtained from the replacement.matrix function.

Value

Returns a list with two elements:

Fx

The replaced (fake) data matrix.

Fperc

Percentage of replaced data.

Author(s)

Massimiliano Pastore

See Also

replacement.matrix

Examples

require(MASS)
set.seed(20130207)
Dx <- rdatagen(R=matrix(c(1,.3,.3,1),2,2),Q=5)$data
RM <- replacement.matrix(p=c(.6,0))
Fx <- rdatarepl(Dx,RM)$Fx

par(mfrow=c(2,2))
for (j in 1:ncol(Dx)) barplot(table(Dx[,j]),main="original data")
for (j in 1:ncol(Fx)) barplot(table(Fx[,j]),main="replaced data")

sgr documentation built on April 14, 2022, 5:08 p.m.

Related to rdatarepl in sgr...