getDataForAllScens: Get data from an rdf file(s) for multiple scenarios and save...

Description Usage Arguments Value See Also Examples

View source: R/getDataFromRdf.R

Description

getDataForAllScens gets slot data from multiple rdf files and for multiple scenarios. The slot data can be aggregated in multiple ways (see createSlotAggList). Slot data is then converted to a molten data frame using reshaphe2::melt and saved as a txt file for later use.

Usage

1
2
getDataForAllScens(scenFolders, scenNames, slotAggList, scenPath, oFile,
  retFile = FALSE)

Arguments

scenFolders

A string vector containing the folder names (scenarios) that the rdf files are saved in.

scenNames

A string vector containing the scenario names. This should be the same length as scenFolders. The scenario names are used as attributes to the data in the "Scenario" column.

slotAggList

The slot aggregation list. A list containing the slots that will be imported and aggregated, the aggregation method(s) to use, and the rdf files that contain the slots. Either created by calling createSlotAggList with a specified set of slots, or a list of lists with each entry containing an rdf file and the keyword 'all' for the slots, e.g., list(list(rdf = 'KeySlots.rdf',slots = 'all')), which will return all of the slots found in an rdf file. If this option is used, the code will return monthly, or annual data, i.e., no aggregation methods will be applied to the data in the rdf file.

scenPath

An absolute or relative path to the folder containing scenFolders.

oFile

An absolute or relative path with the file name of the location the table will be saved to. Valid file types are .csv, .txt, or .feather.

retFile

If TRUE, the data frame will be saved to oFile and returned. If FALSE, the data frame will only be saved to oFile.

Value

If retFile is TRUE, a dataframe, otherwise nothing is returned.

See Also

createSlotAggList

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# get a specified set of slots and apply some aggregation method to them
scenFolders <- c('DNF,CT,IG', 'DNF,CT,IG,Ops1') # get the data from two scenarios
scenNames <- scenFolders
# slotAggTable.csv lists the slots to obtain, and the aggregation method to apply to them
slotAggList <- createSlotAggList(system.file('extdata','SlotAggTable.csv',package = 'RWDataPlot'))
scenPath <- system.file('extdata','Scenario/',package = 'RWDataPlot')
oFile <- 'tmp.feather'
retFile <- TRUE # return the data, instead of only save it as a text file
keyData <- getDataForAllScens(scenFolders, scenNames, slotAggList, scenPath, oFile, retFile)

# get all of the data from the KeySlots rdf file
scenFolders <- scenNames <- scenNames[1] # only one scenario
slotAggList <- list(list(rdf = 'KeySlots.rdf', slots = 'all'))
# will return monthly data for all slots in KeySlots.rdf
allData <- getDataForAllScens(scenFolders, scenNames, slotAggList, scenPath, oFile, retFile)

rabutler/RWDataPlot documentation built on May 26, 2019, 8:51 p.m.