I have tried a lot of alternatives, including the one we can find on Revo website
xform <- function(data) {
data$.rxRowSelection <- as.logical(rbinom(nr, 1 , 0.5))
return(data)
}
rxDataStep(inData = "two_vars.xdf", outFile = "testSample",
transformFunc = xform , overwrite = TRUE)
when nr
is info$numRows
from rxGetInfo("two_vars.xdf")
rxDataStep(inData = "two_vars.xdf", outFile = "testSample",
rowSelection = as.logical(rbinom(nr, 1, 0.5)), overwrite = TRUE)
ERROR: The sample data set for the analysis has no variables. Error in doTryCatch(return(expr), name, parentenv, handler) : std::exception
thanks for helping !
Try this:
xform <- function(data) {
data$.rxRowSelection <- as.logical(rbinom(.rxNumRows, 1 , 0.5))
return(data)
}
rxDataStep(inData = "two_vars.xdf", outFile = "testSample",
transformFunc = xform , overwrite = TRUE)
Or equivalently:
rxDataStep(inData = "two_vars.xdf", outFile = "testSample",
rowSelection = as.logical(rbinom(.rxNumRows, 1 , 0.5)),
overwrite = TRUE)
I think there were two issues with what you were doing.
transformObjects
into the transform environment to use them.