importDataFromSBDF
Import Data from an SBDF File
Description
Imports a file from the Spotfire binary data file format.
Usage
importDataFromSBDF(file = NULL, rowNamesCol = -1,
check.names = FALSE, stringsAsFactors = FALSE)
Arguments
file |
a character string specifying the name of the SBDF to import.
|
rowNamesCol |
an integer denoting the column that should be used for row names.
The specified column is dropped from the resulting data frame.
|
check.names |
a logical value. If FALSE (the default), import the column names
with no changes. If TRUE, convert the imported column names to
legal object names by substituting periods for illegal characters such
as blanks, parentheses, or commas.
|
stringsAsFactors |
a logical value. If stringsAsFactors=TRUE,
strings are converted to factors when they are imported.
The default is FALSE, which imports strings as characters.
|
Details
The following table shows the supported data types
and how they are converted when you import from Spotfire into an R engine:
| SBDF data type | R data type |
| Boolean | logical |
| Integer (32 bit) | numeric |
| Currency* | numeric |
| LongInteger (64 bit) | numeric |
| SingleReal (32-bit float) | numeric |
| Real (64-bit float) | numeric |
| String | character |
| DateTime | POSIXct object with time zone UTC |
| Date | POSIXct object with time zone UTC |
| Time | POSIXct object with time zone UTC,
specifying a time on the R epoch day 1/1/1970 |
| TimeSpan | difftime object with units secs |
| Binary | raw |
|
Most of the supported R data types are stored as data.frame
columns containing atomic vectors. One exception is the raw data
type, which is stored in a data.frame column as a list of raw
objects and NULL values, such as
data.frame(x=I(list(as.raw(1:3),as.raw(4:90),NULL))). The raw objects
in such a list can have different lengths.
*Note: Spotfire Enterprise Runtime for R does not support the Spotfire data type Currency
natively. Any Currency value contained in an SBDF file is imported to
Spotfire Enterprise Runtime for R as numeric. If this numeric is then exported to an SDBF, it is
converted to the Spotfire data type Real. This can result in a loss of
precision for very large values.
The returned data.frame has an added attribute "SBDFImportTypes", whose
value is a named string vector, where the names are the column names,
and the values are the original SBDF data types of the imported columns.
This vector is also returned by the function
getSBDFImportTypes.
The SBDF file format can represent a set of "data table properties"
associated with the whole table, as well as a set of "column properties"
values associated with each table column. Imported data table
properties (if any) are represented by a "SpotfireTableMetaData"
attribute on the return value, and column properties for each column (if
any) are represented by a "SpotfireColumnMetaData" attribute on
the column elements. The value of a "SpotfireTableMetaData" or
"SpotfireColumnMetaData" attribute will be a list of named
elements, where each element can be one of the supported R data types
that are listed above.
Value
returns the imported data as a data.frame.
See Also
Examples
# Import the sample data file, pima.sbdf
pimaFile <- system.file("sample/pima.sbdf", package="SpotfireData")
pima <- importDataFromSBDF(pimaFile)