spssdata.SetDataToSPSS Function (R)

spssdata.SetDataToSPSS(datasetName,x,categoryDictionary). Populates the case data for a new IBM® SPSS® Statistics dataset.

  • The argument datasetName is the name of the IBM SPSS Statistics dataset as specified on the call to the SetDictionaryToSPSS function used to create the dataset.
  • The argument x is an R data frame whose rows represent cases and whose columns represent the variables of the resulting IBM SPSS Statistics dataset. Values in the first column of the data frame populate the first variable in the dataset, values in the second column of the data frame populate the second variable in the dataset, and so on.
  • The optional argument categoryDictionary specifies the name of a category dictionary created with the GetCategoricalDictionaryFromSPSS function. Category dictionaries are for use when retrieving categorical variables (variables with a measurement level of "nominal" or "ordinal") into labelled R factors, with the intention of writing those factors to a new dataset.
  • The SetDictionaryToSPSS function must be called prior to calling SetDataToSPSS in order to specify the dictionary for the new dataset.
  • Logical, integer, and double values from R are mapped to numeric values in IBM SPSS Statistics.
  • For numeric variables, the R NaN and NA values are converted to the system-missing value in IBM SPSS Statistics.
  • When setting values for a IBM SPSS Statistics variable with a date or datetime format, specify the values as R POSIXt objects, which will then be correctly converted to the values appropriate for IBM SPSS Statistics. Also note that IBM SPSS Statistics variables with a time format are stored as the number of seconds from midnight.

Examples of using the SetDataToSPSS function are best understood in the context of creating a new dataset. See the topic Writing Results to a New IBM SPSS Statistics Dataset (R) for more information.