I'm trying to find out what these functions do but I can't find much information on it and it is not very clear from what I have found out. What do they do?
1 Answers
When you start out using Revo R or see demonstrations given, it's common to see functions being applied directly to a file path, like this:
# Create a point to an insurance claims dataset installed with RRE
xdfPath <- file.path(rxGetOption("sampleDataDir"), "claims.xdf")
rxDataStep(xdfPath, numRows = 6)
Behind the scenes, though, rxDataStep
is creating a wrapper around that file path with the information it needs to work with it - the file type, which variables to read, whether character vectors should be converted to factors, etc. That wrapper is called a "data source", and RxXdfData
is the function used to create it. RxTextData
is the same thing, just for text files:
# Create a point to an insurance claims dataset installed with RRE
textPath <- file.path(rxGetOption("sampleDataDir"), "claims.txt")
rxDataStep(textPath, numRows = 6)
You can often just let the RRE functions take care of this for you. Creating a data source can be useful if you have a file that should have different default settings in different analyses. They also have one other advantage: because a data source is a real R object, instead of just a file path, you can use a handful open-source R functions on them:
# This doesn't work like we'd expect:
head(xdfPath)
# These do:
xdfSource <- RxXdfData(xdfPath)
head(xdfSource)
names(xdfSource)
nrow(xdfSource)
summary(xdfSource)
Which is neat but not world-changing.
rxXdfToDataFrame
just lets you convert an XDF file into an in-memory data frame, like this:
rxXdfToDataFrame(xdfSource)
... which is also what rxDataStep
does if you don't give it an outFile
, so I usually use rxDataStep
because it's easier to type.

- 6,405
- 6
- 28
- 69

- 26,709
- 7
- 54
- 72
-
Thanks Matt that makes more sense now....one question if you use rxDataStep and don't specify an outFile, do you need to state overwrite as False for it to convert the xdf into a data frame in memory? – vis7 Aug 18 '15 at 08:31
-
@vis7 overwrite only applies when you're writing to an XDF file, so no problem there. You do need to assign it a name, though - something like: `claims <- rxDataStep(textPath)` – Matt Parker Aug 18 '15 at 22:53