Spreadsheet(FilePathOrName)

Spreadsheet(path.or.object, [applySelectionConditions], [recodeTe xtLabelAsFactors], [recodeMissingDataToNA], [getCaseNames], [getTextValues], [attachObject], [username], [password], [connection string], [stationname])

path.or.object – character vector (literal or variable) or a valid COM object pointing to a Statistica spreadsheet, e.g. “c:/data/sample.sta”, “enterprise://SomeFolder1/SomeFile.sta” or “adstudy”

applySelectionConditions – TRUE (default) or FALSE flag indicating whether selection conditions defined on spreadsheet should be employed

recodeTextLabelCodesAsFactors – TRUE (default) or FALSE flag indicating whether text labels defined for variables should be treated as factors or text

getCaseNames – TRUE (default) or FALSE flag indicating whether row names should be fetched

attachObject – TRUE or FALSE (default) flag indicating whether spreadsheet should be attached to data frame as an “Object”attribute username, password, connectionstring,

stationname – character strings (default value: “”) to be used to fetch spreadsheets from the enterprise system when user does not have an integrated login

Use the Spreadsheet() extension to load a specific Statistica data file into R and transfer the data in that file to an R data frame.

Similar to the ActiveDataSet keyword, the return value of the Spreadsheet() function should be treated as a data frame variable with the contents closely matching that of the corresponding Statistica spreadsheet.

One useful feature supported by this function is the use of default search paths for spreadsheet files that are specified only as simple file names. This means that if the function parameter consists only of a file name, e.g., Spreadsheet(“some.sta”), R Integration Support code will look for this file in several locations: first, it will check the folder where the R script itself is located (if it was saved to disk), and then it will check the Examples\Datasets folder for the current Statistica installation. Support code will also append the default .sta file extension if one is not present. Therefore the following options are available:

  • R scripts can reference the accompanying data sets (placed in the same folder) simply by name
  • Spreadsheets that are included in every Statistica installation as demonstration/example data sets can be referenced by name in much the same way as built-in R data sets

Example:

Spreadsheet("c:\myfiles\mydata.sta") # display the dataset in R console

Spreadsheet("\\server\share\data.sta") # same, but read from a network share

Spreadsheet("thisdemo.sta") # file in the same folder as this script

Spreadsheet("enterprise://folder/thisdemo.sta") # file in Statistica Enterprise

# plot a histogram for MEASURE05 variable from Statistica example dataset Adstudy: hist(Spreadsheet("Adstudy")$MEASURE05)

advert = Spreadsheet("Adstudy")$ADVERT # retrieve a data frame variable (factor)

is.factor(advert)# => [1] TRUE

levels(advert) # => [1] “PEPSI” “COKE”