DataSet: Creates or updates a DataSet

initialize,DataSet-methodR Documentation

Creates or updates a DataSet

Description

Uses the constructors to create the object with its properties or updates an existing one with the setters.

Usage

## S4 method for signature 'DataSet'
initialize(
  .Object,
  compared = FALSE,
  dataProvider,
  fieldMappings,
  stockEvents,
  ...
)

dataSet(compared = FALSE, dataProvider, fieldMappings, stockEvents, ...)

## S4 method for signature 'DataSet,ANY,ANY'
setDataProvider(.Object, dataProvider, keepNA = TRUE)

setFieldMappings(.Object, fieldMappings)

## S4 method for signature 'DataSet,list'
setFieldMappings(.Object, fieldMappings)

addFieldMapping(.Object, ...)

## S4 method for signature 'DataSet'
addFieldMapping(.Object, ...)

setStockEvents(.Object, stockEvents)

## S4 method for signature 'DataSet,list'
setStockEvents(.Object, stockEvents)

addStockEvent(.Object, stockEvent = NULL, ...)

## S4 method for signature 'DataSet,StockEventOrMissing'
addStockEvent(.Object, stockEvent = NULL, ...)

Arguments

.Object

DataSet.

compared

logical.

dataProvider

data.frame, the data set data. Important: the data sets need to come pre-ordered in ascending order. Data with incorrect order might result in visual and functional glitches on the chart.

fieldMappings

list of field mappings. Field mapping is an object with fromField and toField properties. fromField is a name of your value field in dataProvider. toField might be chosen freely, it will be used to set value/open/close/high/low fields for the StockGraph. Example: list(fromField = "val1", toField ="value").

stockEvents

StockEvent.

...

other properties of DataSet.

keepNA

logical, TRUE to keep NA values.

stockEvent

StockEvent. Argument for method addStockEvent.

Value

(updated) DataSet object

Examples

new("DataSet")

dataSet(categoryField = "categoryField")

setDataProvider(.Object = dataSet(), data.frame(key = c("FR", "US"), value = c(20,10)))

dataset <- addFieldMapping(.Object = dataSet(),
                           fieldMappings = list(fromField ="val1", toField ="value"))
print(dataset)
dataset <- addFieldMapping(.Object = dataSet(), fromField ="val1", toField ="value")
print(dataset)
addStockEvent(.Object = dataSet(), backgroundAlpha = 1, backgroundColor = "#DADADA")
# equivalent to:
stockEvent_obj <- stockEvent(backgroundAlpha = 1, backgroundColor = "#DADADA")
chart <- addStockEvent(.Object = dataSet(), stockEvent = stockEvent_obj); print(chart)

rAmCharts documentation built on Sept. 30, 2022, 5:06 p.m.

Related to DataSet in rAmCharts...