R 转换功能可用于转换数据并向该函数传递给 RevoScaleR rxDataStepXdf() 函数。与其他 RevoScaleR 函数,然后可以使用新创建的子集.xdf 文件。下面是一个示例 R 脚本,通过随机取样一个较大的.xdf 文件,使用 transformFunc 中可用的隐藏的行选择变量来创建一个新的.xdf 文件。
# Create a transformFunc that selects 25% of the data at random set.seed(13)
xform <- function(data) {
data$.rxRowSelection<-as.logical(rbinom(length(data[[1]]),1,.25))
return(data)
}
rxDataStepXdf(inFile=inFile, outFile="sampledData.xdf", transformFunc=xform, overwrite=TRUE)
# check that subsetting was done and the row selection variable is not kept in the data set.
rxGetInfoXdf(inFile)
rxGetInfoXdf("sampledData.xdf")