1. Learn
  2. /
  3. Courses
  4. /
  5. Big Data Analysis with Revolution R Enterprise

Exercise

Creating New Variables using rxDataStep

Use the function rxDataStep() function to compute a new variable, airspeed. Air speed should be the distance traveled, divided by the time that has elapsed.

  • rxDataStep() provides a function for transforming variables.

Instructions

100 XP

The rxDataStep function is structured as follows:

  • rxDataStep(inData, outFile, varsToKeep, transforms, append, overwrite)

Let's go over each of these arguments:

  • inData - specifies the dataset from which we extract variables.
  • outFile - specifies the output dataset that we want to create (This can be the same as inData, see append and overwrite below).
  • varsToKeep - the variables to be read from the inData file.
  • transforms - the (simple) transformation to compute.
  • append - either "none" to create a new files, "rows" to append rows to an existing file, or "cols" to append columns to an existing file.
  • overwrite - Logical value to specify whether the output should be overwritten if it already exists.

Use rxDataStep() to create a variable airspeed.

Once you have done this, then use rxGetInfo(), rxSummary(), and rxHistogram() to get some information about the new variable. When using rxGetInfo(), use the varsToKeep argument to only extract information about the new variable. For rxSummary() and rxHistogram(), remember that you specify a formula as the first argument.