importData
Import a Data File

Description

Imports values from an external data file and creates a data frame. The data file must be in an external format supported by the StatTransfer product.

Usage

importData(file = "", format = NULL, drop = NULL, keep = NULL,
    control = NULL, stringsAsFactors = default.stringsAsFactors(),
    check.names = TRUE)

Arguments

file a character string containing the name of the file to read. The file extension determines the file format unless the format argument is supplied.
format a character string specifying the format of file. It must be one of the values from the FormatTag column in the stattranFileFormats data set. Typically, this argument is not required because if it is not supplied, the file extension on the file argument determines the format.
drop a character vector of variable names in file that are not included in the data frame created. All other columns are imported. If drop is specified, the keep argument cannot be used.
keep a character vector of column names from file that are imported. Only the columns listed are included in the data frame created. If keep is specified, the drop argument cannot be used.
control a named list of control options for the StatTransfer library. Typically, this is created in a call to stattran.control.
stringsAsFactors a logical flag. If TRUE, then imported character data columns are converted factors whose levels are the unique strings in the column.

Note that as of version 5.2 of TIBCO Enterprise Runtime for R, default.stringsAsFactors() returns FALSE instead of the previous TRUE unless the user has execututed options(stringsAsFactors=TRUE) earlier in the session. This matches the same change in version 4.0.0 of open-source R.

check.names a logical flag. If TRUE (the default), then variable names are changed to legal object names by substituting . for illegal characters such as blanks, parentheses, or commas. (See make.names for details.)

Details

The control option table can be used to specify which sheet to import from a spreadsheet.
The control option num-miss-rd can be used with ASCII files to specify a string in a numeric column that should be considered a missing value.
The maximum column name length for import is 128 characters. Column names in import files that are longer will be truncated to 128 characters.
Value
returns a data frame created from the values in file.
References
StatTransfer Manual, http://www.stattransfer.com/support/manual, Circle Systems, Seattle, WA.
See Also
exportData, stattran.control, stattranFileFormats, stattranOptionValues
Examples
tf01 <- paste0(tempfile(), ".csv")
df01 <- data.frame(x = 1:5, c = letters[11:15],
    d = seq.Date(as.Date("2011-05-23"), by=1, length.out=5))
n <- exportData(df01, file=tf01)
importData(tf01)

## Not run: # Read the sheet Helena from the CityIncome.xlsx file: importData("CityIncome.xlsx", control=list("table" = "Helena")) ## End(Not run)

## Not run: # Set "miss" in numeric columns to missing (NA): importData("nyc_rats.csv", control=list("num-miss-rd"="miss")) ## End(Not run)

Package stattran version 6.0.0-69
Package Index