rdatarepl {sgr} | R 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 |
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
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")
[Package sgr version 1.3.1 Index]