Package LSDinterface

Similar documents
Package slam. December 1, 2016

Package MonteCarlo. April 23, 2017

Package crossword.r. January 19, 2018

Package csvread. August 29, 2016

Package slam. February 15, 2013

Data Structures STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley

Package flsa. February 19, 2015

Package kirby21.base

Package spark. July 21, 2017

Package ECctmc. May 1, 2018

Package filematrix. R topics documented: February 27, Type Package

Package datasets.load

Package readxl. April 18, 2017

Package erp.easy. March 2, 2017

Package dyncorr. R topics documented: December 10, Title Dynamic Correlation Package Version Date

Package jdx. R topics documented: January 9, Type Package Title 'Java' Data Exchange for 'R' and 'rjava'

Package librarian. R topics documented:

STAT 540 Computing in Statistics

Package rhor. July 9, 2018

Package strat. November 23, 2016

Package clustering.sc.dp

Package hypercube. December 15, 2017

Package Combine. R topics documented: September 4, Type Package Title Game-Theoretic Probability Combination Version 1.

Package areaplot. October 18, 2017

Package tibble. August 22, 2017

Package crochet. January 8, 2018

Package PRISMA. May 27, 2018

Package fastdummies. January 8, 2018

Package enpls. May 14, 2018

Package nmslibr. April 14, 2018

Package Numero. November 24, 2018

Package bisect. April 16, 2018

Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package narray. January 28, 2018

Package nprotreg. October 14, 2018

Package Matrix.utils

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package TPD. June 14, 2018

Package woebinning. December 15, 2017

Package recosystem. September 2, 2017

Package gifti. February 1, 2018

Description/History Objects/Language Description Commonly Used Basic Functions. More Specific Functionality Further Resources

Package utf8. May 24, 2018

Package zip. R topics documented: March 11, Title Cross-Platform 'zip' Compression Version 2.0.1

Package weco. May 4, 2018

The SQLiteDF Package

Package apastyle. March 29, 2017

Reading and wri+ng data

Package mfbvar. December 28, Type Package Title Mixed-Frequency Bayesian VAR Models Version Date

Package getopt. February 16, 2018

Package UNF. June 13, 2017

Package DPBBM. September 29, 2016

Package RCA. R topics documented: February 29, 2016

Package mmpa. March 22, 2017

Package Rglpk. May 18, 2017

Package PropClust. September 15, 2018

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package sfc. August 29, 2016

Package ggseas. June 12, 2018

Package StatMeasures

Mails : ; Document version: 14/09/12

Package Rwinsteps. February 19, 2015

Package embed. November 19, 2018

Package rscala. November 25, 2017

Package WriteXLS. March 14, 2013

Package inca. February 13, 2018

Package redux. May 31, 2018

Package sigqc. June 13, 2018

Package LVGP. November 14, 2018

Package RaPKod. February 5, 2018

Package clipr. June 23, 2018

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package rmumps. September 19, 2017

Package ANOVAreplication

Package postgistools

Package TVsMiss. April 5, 2018

Package CorporaCoCo. R topics documented: November 23, 2017

Package blockmatrix. February 19, 2015

R: BASICS. Andrea Passarella. (plus some additions by Salvatore Ruggieri)

Package SIRItoGTFS. May 21, 2018

Package kernelfactory

Package balance. October 12, 2018

Package CatEncoders. March 8, 2017

Package multipol. R topics documented: March 20, 2018

Package multilaterals

Package varhandle. R topics documented: July 4, 2018

Package jstree. October 24, 2017

Package RaschSampler

Package AdhereR. June 15, 2018

Package splithalf. March 17, 2018

Package mvprobit. November 2, 2015

Package loggit. April 9, 2018

Package ClusterBootstrap

Introduction to R. UCLA Statistical Consulting Center R Bootcamp. Irina Kukuyeva September 20, 2010

Package PCADSC. April 19, 2017

Package orthogonalsplinebasis

Package CINID. February 19, 2015

Data types and structures

Package estprod. May 2, 2018

Package svalues. July 15, 2018

Transcription:

Type Package Title Reading LSD Results (.res) Files Version 0.3.1 Date 2017-11-24 Author Package LSDinterface November 27, 2017 Maintainer <marcelocpereira@uol.com.br> Interfaces R with LSD. Reads object-oriented data in results files (.res) produced by LSD and creates appropriate multi-dimensional arrays in R. Supports multiple core parallelization of multi-file data reading for increased performance. Also provides functions to extract basic information and statistics from data files. LSD (Laboratory for Simulation Development) is free software developed by Marco Valente (documentation and downloads available at <http://labsimdev.org>). Depends R (>= 3.2.0) Imports stats, utils, abind, parallel License GPL-3 LazyData true NeedsCompilation no Repository CRAN Date/Publication 2017-11-27 21:09:26 UTC R topics documented: LSDinterface-package................................... 2 info.details.lsd........................................ 3 info.dimensions.lsd..................................... 4 info.init.lsd......................................... 5 info.names.lsd........................................ 6 info.stats.lsd......................................... 7 name.check.lsd....................................... 9 name.clean.lsd........................................ 10 name.nice.lsd........................................ 11 1

2 LSDinterface-package name.var.lsd......................................... 12 read.3d.lsd.......................................... 13 read.4d.lsd.......................................... 14 read.list.lsd......................................... 16 read.multi.lsd........................................ 18 read.raw.lsd......................................... 20 read.single.lsd........................................ 21 select.colattrs.lsd...................................... 22 select.colnames.lsd..................................... 24 Index 26 LSDinterface-package Reading LSD Results (.res) Files Interfaces R with LSD. Reads object-oriented data in results files (.res) produced by LSD and creates appropriate multi-dimensional arrays in R. Supports multiple core parallelization of multi-file data reading for increased performance. Also provides functions to extract basic information and statistics from data files. LSD (Laboratory for Simulation Development) is free software developed by Marco Valente (documentation and downloads available at <http://labsimdev.org>). Details There are specific read.xxx.lsd functions for different types of LSD data structures. read.raw.lsd simply import LSD saved data in tabular (data frame) format (variables in columns and time steps in rows). read.single.lsd is appropriate to simple LSD data structures where each saved variable is single-instanced (inside an object with a single copy). read.multi.lsd reads all instances of all variables from the LSD results file, renaming multi-instanced variables. read.list.lsd is similar to read.multi.lsd but saves multiple-instanced variables as R lists, preventing renaming. read.3d.lsd and read.4d.lsd are specialized versions for extracting data from multiple LSD results files simultaneously. The files must have the same structure (selected variables and number of time steps). They are frequently used to acquire data from Monte Carlo experiments or sensitivity analysis. read.3d.lsd operates like read.single.lsd but add each additional results file into a separate dimension of the produced 3-dimensional array (variable x time step x file). read.4d.lsd adds the ability to read each instance of a multi-instanced variable to the fourth dimension of the generated 4D array (variable x instance x time step x file). select.colattrs.lsd and select.colnames.lsd provide methods to extract/summarize information from previously imported LSD data structures. info.xxx.lsd functions provide information about LSD data structures. name.xxx.lsd functions offer tools for dealing with LSD variable names in R. For a complete list of exported functions, use library(help = "LSDinterface").

info.details.lsd 3 Maintainer: <marcelocpereira@uol.com.br> References LSD documentation is available at http://labsimdev.org The latest LSD binaries and source code can be downloaded at https://github.com/marcov64/lsd. info.details.lsd Get detailed information from a LSD results file This function reads, analyze and organize the information from a LSD results file (.res). info.details.lsd(file) file the name of the LSD results file which the data are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). Tilde-expansion is performed where supported. This can be a compressed file (see file) and must include the appropriated extension (usually.res or.res.gz). Returns a data frame containing detailed description (columns) of all variables (rows) contained in the selected results file. info.init.lsd, info.names.lsd info.dimensions.lsd

4 info.dimensions.lsd info1 <- info.details.lsd("sim1_1.res") #View(info1) info2 <- info.details.lsd("sim1_2.res.gz") #View(info2) # Restore working directory setwd(currwd) info.dimensions.lsd Dimension information for a LSD results file This function reads some dimension information from a LSD results file (.res): number of time steps, number of variables and the original column (variable) names. info.dimensions.lsd(file) file the name of the LSD results file which the data are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). Tilde-expansion is performed where supported. This can be a compressed file (see file) and must include the appropriated extension (usually.res or.res.gz). Details The returned number of time steps does not include the initial value (t = 0) for lagged variables (the second line of a.res format file). Returns a list containing two integer values and a character vector describing the selected results file. tsteps nvars varnames Number of time steps in file Number of variables (including duplicated instances) in file Names of variables (including duplicated instances) in file, after R name conversion

info.init.lsd 5 info.details.lsd, info.names.lsd, info.init.lsd info.dimensions.lsd("sim1_1.res") info.dimensions.lsd("sim1_2.res.gz") # Restore working directory setwd(currwd) info.init.lsd Read initial conditions from a LSD results file This function reads the initial condition values from a LSD results file (.res). info.init.lsd(file) file the name of the LSD results file which the data are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). Tilde-expansion is performed where supported. This can be a compressed file (see file) and must include the appropriated extension (usually.res or.res.gz). Note Returns a 1 line matrix containing the initial conditions (row 1) of all variables contained in the selected results file. The returned matrix contains all variables in the results file, even the ones that don t have an initial condition (indicated as NA). Only variables automatically initialized automatically by LSD in t = 1 are included here.

6 info.names.lsd info.details.lsd, info.names.lsd info.dimensions.lsd init1 <- info.init.lsd("sim1_1.res") #View(init1) init2 <- info.init.lsd("sim1_2.res.gz") #View(init2) # Restore working directory setwd(currwd) info.names.lsd Read unique variable names from a LSD results file (no duplicates) This function reads the variable names (columns) from a LSD results file (.res). The names returned are converted to the original LSD names whenever possible and duplicates are removed. info.names.lsd(file) file the name of the LSD results file which the data are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). Tilde-expansion is performed where supported. This can be a compressed file (see file) and must include the appropriated extension (usually.res or.res.gz). Returns a character vector containing the names of all unique variables contained in the selected results file.

info.stats.lsd 7 Note Not all names can be automatically reconverted to the original LSD names. The conversion may be incorrect if the original LSD variable is named in the format "X_...". info.details.lsd, info.init.lsd info.dimensions.lsd info.names.lsd("sim1_1.res") info.names.lsd("sim1_2.res.gz") # Restore working directory setwd(currwd) info.stats.lsd Compute Monce Carlo statistics from a set of LSD runs This function reads a 3 or 4-dimensional array produced by read.3d.lsd or read.4d.lsd and produces a list with 2D data frames containing the average, the standard deviation, the maximum and the mininum for each variable, at each time step. info.stats.lsd(array, rows = 1, cols = 2) array rows cols an 3D or 4D array as produced by read.3d.lsd and read.4d.lsd, where in the first dimension (rows) you have the time steps, in the second (columns), the variables and in the third/fourth dimension, the Monte Carlo experiments, and the instances in the third dimension (4D arrays only). integer: array dimension to be used as the rows for the statistics matrices, default is to use first array dimension. integer: array dimension to be used as the columns for the statistics matrices, default is to use second array dimension.

8 info.stats.lsd Returns a list containing four matrices, with the original size and naming of the selected 2 dimensions of the argument. avg sd max min a matrix with the average of the MC experiments a matrix with the standard deviation of the MC experiments a matrix with the maximum value of the MC experiments a matrix with the minimum value of the MC experiments read.3d.lsd, read.4d.lsd, info.dimensions.lsd # reads first instance of all variables from three MC files (3D array) inst1array <- read.3d.lsd(c("sim1_1.res", "Sim1_2.res", "Sim1_3.res")) # creates statistics data frames for the variables inst1stats <- info.stats.lsd(inst1array) # See matrix in the data viewer (require package 'utils') #View(inst1Stats) # organize the stats by variable (dim=2) and file (dim=3) inst1stats2 <- info.stats.lsd(inst1array, rows = 2, cols = 3) #View(inst1Stats2) # the same but for all instance of all variables (from a 4D array) allarray <- read.4d.lsd(c("sim1_1.res", "Sim1_2.res", "Sim1_3.res")) allstats <- info.stats.lsd(allarray) #View(allStats) # organize the stats by file (dim=4) and variable (dim=2) allstats2 <- info.stats.lsd(allarray, rows = 4, cols = 2) #View(allStats2) # Restore working directory setwd(currwd)

name.check.lsd 9 name.check.lsd Check a set of LSD variables names against a LSD results file This function checks if all variable names in a set are valid for a LSD results file (.res). If no name is provided, the function returns all the valid unique variable names in the file. name.check.lsd(file, col.names = NULL, check.names = TRUE) file col.names check.names the name of the LSD results file which the data are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). This can be a compressed file (see file) and must include the appropriated extension (usually.res or.res.gz). a vector of optional names for the variables. The default is to read all (unique) variables. logical. If TRUE then the names of the variables are checked to ensure that they are syntactically valid variable names. If necessary they are adjusted (by make.names) so that they are, and also to ensure that there are no duplicates. Returns a character vector containing the valid variable names contained in the results file. info.names.lsd, name.check.lsd("sim1_1.res") name.check.lsd("sim1_1.res", col.names = c("gdp", "_growth1")) # Restore working directory setwd(currwd)

10 name.clean.lsd name.clean.lsd Get clean (R) variable name This function produces a more appropriate variable name from R initial column name conversion. name.clean.lsd(r.name) r.name a character vector, or an object which can be coerced to a character vector by as.character, from the column names produced by reading a LSD results file. Details The function removes the extra/ending. characters introduced by R and introduces a _ between time span values. A character vector of with the same attributes as x (after possible coercion) and the format "NAME.POSITION.INI_END". name.var.lsd, name.nice.lsd, info.names.lsd name.clean.lsd("var1.1_1..1.100.") name.clean.lsd(c("var1.1_1..1.100.", "Var2.1_2_3..50.70."))

name.nice.lsd 11 name.nice.lsd Get a nice (R) variable name This function produces a nicer variable name from R initial column name conversion, in particular removing leading underscores. name.nice.lsd(r.name) r.name a character vector, or an object which can be coerced to a character vector by as.character, from the column names produced by reading a LSD results file. Details The function removes the extra/ending. characters introduced by R and introduces a _ between time span values and deletes leading underscores ( _ ), converted to X_ by R. A character vector of with the same attributes as x (after possible coercion) and the format "NAME[.POSITION.INI_END]". name.var.lsd, name.clean.lsd, info.names.lsd name.nice.lsd("x_var1.1_1..1.100.") name.nice.lsd(c("_var1.1_1..1.100.", "X_Var2.1_2_3..50.70.")) name.nice.lsd(c("_var1", "X_Var2"))

12 name.var.lsd name.var.lsd Get original LSD variable name This function generates the original LSD variable name, as it was defined in LSD and before R adjusts the name, from a R column name (with or without position or timing information appended). name.var.lsd(r.name) r.name a character vector, or an object which can be coerced to a character vector by as.character, from the column names produced by reading a LSD results file. Details The conversion may be incorrect if the original LSD variable is named in the format "X_...". No checking is done to make sure the variable really exists. A character vector of with the same attributes as x (after possible coercion). name.clean.lsd, info.names.lsd name.var.lsd("label") name.var.lsd(c("label", "X_underlinelabel"))

read.3d.lsd 13 read.3d.lsd Read one instance of LSD variables (time series) from multiple LSD results files into a 3D array This function reads the data series associated to a specific instance of each selected variable from a set of LSD results files (.res) and saves them into a 3-dimensional array (time step x variable x file). read.3d.lsd(files, col.names = NULL, nrows = -1, skip = 0, check.names = TRUE, instance = 1, nnodes = 1) files col.names nrows skip check.names instance nnodes a character vector containing the names of the LSD results files which the data are to be read from. If they do not contain an absolute path, the file names are relative to the current working directory, getwd(). These can be compressed files and must include the appropriated extension (usually.res or.res.gz). a vector of optional names for the variables. The default is to read all variables. integer: the maximum number of time steps (rows) to read in. Negative and other invalid values are ignored. The default is to read all rows. integer: the number of time steps (rows) of the results file to skip before beginning to read data. The default is to read from the first time step (t = 1). logical. If TRUE then the names of the variables are checked to ensure that they are syntactically valid variable names. If necessary they are adjusted (by make.names) so that they are, and also to ensure that there are no duplicates. integer: the instance of the variable to be read, for variables that exist in more than one object. This number is based on the position (column) of the variable in the results file. The default (1) is to read first instances. integer: the maximum number of parallel computing nodes (parallel threads) in the current computer to be used for reading the files. The default, nnodes = 1, means single thread processing (no parallelization). If equal to zero, creates up to one node per CPU core. Only "PSOCK" clusters are used, to ensure compatibility with any platform. Please note that each node requires its own memory space, so memory usage increases linearly with the number of nodes. Note Returns a 3D array containing data series from the selected variables. If the selected files don t have the same columns available (names and instances), an error is produced.

14 read.4d.lsd read.4d.lsd, read.single.lsd, read.multi.lsd, read.list.lsd, read.raw.lsd # reads first instance of all variables from three files (one level each) inst1array <- read.3d.lsd(c("sim1_1.res", "Sim1_2.res", "Sim1_3.res")) # See parts of the 3D array in the data viewer (require package 'utils') #View(inst1Array[,,1]) #View(inst1Array[,,2]) #View(inst1Array[,,3]) # read first instance of a set of variables named '_A1p' and '_growth1' ab1array <- read.3d.lsd(c("sim1_1.res.gz", "Sim1_2.res.gz", "Sim1_3.res.gz"), c("_a1p", "_growth1")) #View(ab1Array[,,1]) #View(ab1Array[,,2]) #View(ab1Array[,,3]) # reads instance 2 of all variables, skipping the initial 20 time steps # and keeping up to 50 time steps (from t = 21 up to t = 70) inst2array21_70 <- read.3d.lsd(c("sim1_1.res", "Sim1_2.res"), skip = 20, nrows = 50, instance = 2) #View(inst2Array21_70[,,1]) #View(inst2Array21_70[,,2]) # Restore working directory setwd(currwd) read.4d.lsd Read all instances of LSD variables (time series) from multiple LSD results file into a 4D array This function reads the data series associated to all instances of each selected variable from a set of LSD results files (.res) and saves them into a 4-dimensional array (time step x variable x instance x file). read.4d.lsd(files, col.names = NULL, nrows = -1, skip = 0, check.names = TRUE, pool = FALSE, nnodes = 1)

read.4d.lsd 15 files col.names nrows skip check.names pool nnodes a character vector containing the names of the LSD results files which the data are to be read from. If they do not contain an absolute path, the file names are relative to the current working directory, getwd(). These can be compressed files and must include the appropriated extension (usually.res or.res.gz). a vector of optional names for the variables. The default is to read all variables. integer: the maximum number of time steps (rows) to read in. Negative and other invalid values are ignored. The default is to read all rows. integer: the number of time steps (rows) of the results file to skip before beginning to read data. The default is to read from the first time step (t = 1). logical. If TRUE then the names of the variables are checked to ensure that they are syntactically valid variable names. If necessary they are adjusted (by make.names) so that they are, and also to ensure that there are no duplicates. logical. If TRUE, variables instances from all files are concatenated (by colums) as a single file. If FALSE (the default), each file is saved as a separated dimension (4th) in the array. integer: the maximum number of parallel computing nodes (parallel threads) in the current computer to be used for reading the files. The default, nnodes = 1, means single thread processing (no parallelization). If equal to zero, creates up to one node per CPU core. Only "PSOCK" clusters are used, to ensure compatibility with any platform. Please note that each node requires its own memory space, so memory usage increases linearly with the number of nodes. Returns a 4D array containing data series for each instance from the selected variables. Note If the selected files don t have the same columns available (names), an error is produced. When pool = TRUE, the produced array is still 4-dimensional but the fourth dimension has just one value (= 1). Pooling require that all files contains EXACTLY the same variables (number of instances may be different). read.3d.lsd, read.single.lsd, read.multi.lsd, read.list.lsd, read.raw.lsd

16 read.list.lsd # reads all instance of all variables from three files allarray <- read.4d.lsd(c("sim1_1.res", "Sim1_2.res", "Sim1_3.res")) # See parts of the 4D array in the data viewer (require package 'utils') #View(allArray[,,1,1]) # first instance of first file (all vars and times) #View(allArray[,9,,2]) # all instances of ninth variable in second file (all t's) #View(allArray[50,8,,]) # all instances of all files of 8th variable for t=50 # the same, but pooling all files into a single one allarraypool <- read.4d.lsd(c("sim1_1.res", "Sim1_2.res", "Sim1_3.res"), pool = TRUE) #View(allArrayPool[,,1,1]) # first instance of first file (all vars and times) #View(allArrayPool[,9,,1]) # all instances of ninth variable in second file (all t's) #View(allArrayPool[50,8,,]) # all instances of all files of 8th variable for t=50 # read instances of a set of variables named '_A1p' and '_growth1' abarray <- read.4d.lsd(c("sim1_1.res.gz", "Sim1_2.res.gz", "Sim1_3.res.gz"), c("_a1p", "_growth1")) #View(abArray[,,1,2]) # first instances of second file (all vars and times) #View(abArray[,2,,3]) # all instances of second variable in third file (all t's) #View(abArray[50,1,,]) # all instances of all files of first variable for t=50 # reads all variables/variables, skipping the initial 20 time steps # and keeping up to 50 time steps (from t = 21 up to t = 70) allarray21_70 <- read.4d.lsd(c("sim1_1.res", "Sim1_2.res"), skip = 20, nrows = 50) #View(allArray21_70[,9,,2]) # all instances of ninth variable in second file #View(allArray21_70[30,8,,]) # all instances of all files of 8th variable for t=50 # Restore working directory setwd(currwd) read.list.lsd Read one or all instances of LSD variables (time series) from a LSD results file into a list This function reads the data series associated to a specific or all instances of each selected variable from a LSD results file (.res) and saves them into separated matrices (one per variable). read.list.lsd(files, col.names = NULL, nrows = -1, skip = 0, check.names = TRUE, instance = 0, pool = FALSE, nnodes = 1) files a character vector containing the names of the LSD results files which the data are to be read from. If they do not contain an absolute path, the file names are

read.list.lsd 17 col.names nrows skip check.names instance pool nnodes relative to the current working directory, getwd(). These can be compressed files and must include the appropriated extension (usually.res or.res.gz). a vector of optional names for the variables. The default is to read all variables. integer: the maximum number of time steps (rows) to read in. Negative and other invalid values are ignored. The default is to read all rows. integer: the number of time steps (rows) of the results file to skip before beginning to read data. The default is to read from the first time step (t = 1). logical. If TRUE then the names of the variables are checked to ensure that they are syntactically valid variable names. If necessary they are adjusted (by make.names) so that they are, and also to ensure that there are no duplicates. integer: the instance of the variable to be read, for variables that exist in more than one object. This number is based on the position (column) of the variable in the results file. The default (0) is to read all instances. logical. If TRUE, variables instances from all files are concatenated (by colums) into a single matrix. If FALSE (the default), each file is saved as a separated matrix. integer: the maximum number of parallel computing nodes (parallel threads) in the current computer to be used for reading the files. The default, nnodes = 1, means single thread processing (no parallelization). If equal to zero, creates up to one node per CPU core. Only "PSOCK" clusters are used, to ensure compatibility with any platform. Please note that each node requires its own memory space, so memory usage increases linearly with the number of nodes. Returns a list containing matrices with the selected variables time series in the results file. If pool = TRUE, the list contains a single, consolidated matrix (column names are not unique). Note When using the option pool = TRUE, columns from multiple files are consolidated with their original names, so names will not be unique anymore. You may use unique to change column names so they become unique, if required. The returned matrices may be potentially very wide, in particular if variables are not well selected(see col.names above) or if there is a large number of instances. read.single.lsd, read.multi.lsd, read.3d.lsd, read.4d.lsd, read.raw.lsd, unique

18 read.multi.lsd # reads all instances of all variables from three files (one matrix each) tablelist <- read.list.lsd(c("sim1_1.res", "Sim1_2.res", "Sim1_3.res")) # See parts of the 3D array in the data viewer (require package 'utils') #View(tableList[[ 1 ]]) #View(tableList[[ 2 ]]) #View(tableList[[ 3 ]]) # read all instances of a set of variables named '_A1p' and '_growth1' # and pool data abtable <- read.list.lsd(c("sim1_1.res.gz", "Sim1_2.res.gz"), c("_a1p", "_growth1"), pool = TRUE) #View(abTable) # reads instance 4 of all variables, skipping the initial 20 time steps # and keeping up to 50 time steps (from t = 21 up to t = 70) inst4list21_70 <- read.list.lsd(c("sim1_1.res", "Sim1_2.res"), skip = 20, nrows = 50, instance = 4) #View(inst4List21_70[[ 1 ]]) #View(inst4List21_70[[ 2 ]]) read.multi.lsd Read all instances of LSD variables (time series) from a LSD results file This function reads the data series associated to all instances of each selected variable from a LSD results file (.res). read.multi.lsd(file, col.names = NULL, nrows = -1, skip = 0, check.names = TRUE) file col.names nrows skip the name of the LSD results file which the data are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). This can be a compressed file (see file) and must include the appropriated extension (usually.res or.res.gz). a vector of optional names for the variables. The default is to read all variables. integer: the maximum number of time steps (rows) to read in. Negative and other invalid values are ignored. The default is to read all rows. integer: the number of time steps (rows) of the results file to skip before beginning to read data. The default is to read from the first time step (t = 1).

read.multi.lsd 19 check.names logical. If TRUE then the names of the variables are checked to ensure that they are syntactically valid variable names. If necessary they are adjusted (by make.names) so that they are, and also to ensure that there are no duplicates. Returns a list of matrices, each containing one of the selected variables time series from the results file. Note For extracting data from multiple similar files (like sensitivity analysis results), see read.list.lsd. read.single.lsd, read.list.lsd, read.3d.lsd, read.4d.lsd, read.raw.lsd # Load a sample.res file into a simple matrix (all instances) macrolist <- read.multi.lsd("sim1_1.res") # See matrix in the data viewer (require package 'utils') length(macrolist) #View(macroList[[1]]) #View(macroList[[8]]) # reads first instance of 2 variables, skipping the initial 20 time steps # and keeping up to 50 time steps (from t = 21 up to t = 70) varslist21_70 <- read.multi.lsd("sim1_1.res", c("_a1p", "_growth1"), skip = 20, nrows = 50) #View(varsList21_70[[1]]) #View(varsList21_70[[2]]) # Restore working directory setwd(currwd)

20 read.raw.lsd read.raw.lsd Read LSD results file and clean variables names This function reads all the data series in a LSD results file (.res). read.raw.lsd(file, nrows = -1, skip = 0) file nrows skip the name of the LSD results file which the data are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). This can be a compressed file (see file) and must include the appropriated extension (usually.res or.res.gz). integer: the maximum number of time steps (rows) to read in. Negative and other invalid values are ignored. The default is to read all rows. integer: the number of time steps (rows) of the results file to skip before beginning to read data. The default is to read from the first time step (t = 1). Returns a single matrix containing all variables time series contained in the results file. Note The returned matrix may be potentially very wide. For extracting data in a more selective way, see read.single.lsd and read.multi.lsd. To use multiple results files simultaneously, see read.list.lsd and read.3d.lsd. Variable names are never "cleaned", even for single instanced variables. read.single.lsd, read.multi.lsd, read.list.lsd, read.3d.lsd, read.4d.lsd

read.single.lsd 21 # reads all instances of all variables bigtable <- read.raw.lsd("sim1_1.res") # See matrix in the data viewer (require package 'utils') #View(bigTable) ## reads all instances of all variables, skipping the initial 20 time steps ## and keeping up to 50 time steps (from t = 21 up to t = 70) all21_70 <- read.raw.lsd("sim1_2.res.gz", skip = 20, nrows = 50) #View(all21_70) read.single.lsd Read LSD variables (time series) from a LSD results file (a single instance of each variable only) This function reads the data series associated to one instance of each selected variable from a LSD results file (.res). Just a single instance (time series of a single LSD object) is read at each call. read.single.lsd(file, col.names = NULL, nrows = -1, skip = 0, check.names = TRUE, instance = 1) file col.names nrows skip check.names instance the name of the LSD results file which the data are to be read from. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). This can be a compressed file (see file) and must include the appropriated extension (usually.res or.res.gz). a vector of optional names for the variables. The default is to read all (unique) variables. integer: the maximum number of time steps (rows) to read in. Negative and other invalid values are ignored. The default is to read all rows. integer: the number of time steps (rows) of the results file to skip before beginning to read data. The default is to read from the first time step (t = 1). logical. If TRUE then the names of the variables are checked to ensure that they are syntactically valid variable names. If necessary they are adjusted (by make.names) so that they are, and also to ensure that there are no duplicates. integer: the instance of the variable to be read, for variables that exist in more than one object. This number is based on the position (column) of the variable in the results file. The default is to read the first instance.

22 select.colattrs.lsd Note Returns a matrix containing the selected variables time series contained in the results file. This function is useful to extract time series for variables that are single instanced, like summary statistics. For multi-instanced variables, see read.multi.lsd. For extracting data from multiple similar files (like sensitivity analysis results), see read.list.lsd (multi-instanced variables) and read.3d.lsd (single-instanced variables). read.multi.lsd, read.list.lsd, read.3d.lsd, read.4d.lsd, read.raw.lsd # Load a sample.res file into a simple matrix (first instances only) macrovar <- read.single.lsd("sim1_1.res") # See matrix in the data viewer (require package 'utils') #View(macroVar) # read second instance of a set of variables named '_A1p' and '_growth1' ag2table <- read.single.lsd("sim1_2.res.gz", c("_a1p", "_growth1"), instance = 2) #View(ag2Table) # reads first instance of all variables, skipping the initial 20 time steps # and keeping up to 50 time steps (from t = 21 up to t = 70) var21_70 <- read.single.lsd("sim1_1.res", skip = 20, nrows = 50) #View(var21_70) # Restore working directory setwd(currwd) select.colattrs.lsd Select a subset of a LSD results matrix (by variable attributes) This function select a subset of a LSD results matrix (as produced by read.raw.lsd) by the variable attributes, considering the LSD object position and the time span.

select.colattrs.lsd 23 select.colattrs.lsd(dataset, info, col.names = NA, posit = NULL, init.value = NA, init.time = NA, end.time = NA) dataset info col.names posit init.value init.time end.time matrix produced by the invocation of read.raw.lsd, read.single.lsd, read.multi.lsd or read.list.lsd (a single matrix a time) functions. data frame produced by info.details.lsd for the same results file from where dataset was extracted. a vector of optional names for the variables to select from. The default is to select from all variables. a string, a vector of strings or an integer vector describing the LSD object position of the variable(s) to select. If a string or an integer vector, it should define the position of a SINGLE LSD object. If a vector of strings, each element of the vector should define a different LSD object, so the returning matrix will contain variables from more than one object. initial value attributed to the variable(s) to select. initial time attributed to the variable(s) to select. end time attributed to the variable(s) to select. Details Selection restriction parameters can be provided as needed; when not specified, each selection dimension include all available cases. Returns a single matrix containing the selected variables time series contained in the original data set. Note If only variable names selection is needed, select.colnames.lsd is more efficient because information pre-processing (info.details.lsd) is not required. info.details.lsd, select.colnames.lsd

24 select.colnames.lsd # reads all instances of all variables bigtable <- read.raw.lsd("sim1_1.res") # build the info table info <- info.details.lsd("sim1_1.res") # read some instances of a set of variables named '_A1p' and '_growth1' abfirst2 <- select.colattrs.lsd(bigtable, info, c("_a1p", "_growth1"), posit = c("1_2", "1_5")) # See matrix in the data viewer (require package 'utils') #View(abFirst2) # reads instances of variable '_A1p' that start at time step t = 1 a50 <- select.colattrs.lsd(bigtable, info, make.names("_a1p"), init.time = 1) #View(a50) # Restore working directory setwd(currwd) select.colnames.lsd Select a subset of a LSD results matrix (by column/variable names) This function select a subset of a LSD results matrix (as produced by read.raw.lsd) by the column (variable) names, considering only the name part of the column labels. select.colnames.lsd(dataset, col.names, instance = 0) dataset col.names instance matrix produced by the invocation of read.raw.lsd, read.single.lsd, read.multi.lsd or read.list.lsd (a single matrix a time) functions. a vector of optional names for the variables. The default is to read all variables. The names must to be in R format. integer: the instance of the variable to be read, for variables that exist in more than one object. This number is based on the position (column) of the variable in the results file. The default (0) is to read all instances.

select.colnames.lsd 25 Note Returns a single matrix containing the selected variables time series contained in the original data set. The variable/column names must be valid R column names (e.g., names do not start with a underscore). Use make.names if required. select.colattrs.lsd, make.names # reads all instances of all variables bigtable <- read.raw.lsd("sim1_1.res") # See matrix in the data viewer (require package 'utils') #View(bigTable) # extract all instances of a set of variables named '_A1p' and '_growth1' abtable <- select.colnames.lsd(bigtable, make.names(c("_a1p", "_growth1"))) #View(abTable) # Restore working directory setwd(currwd)

Index Topic attribute info.details.lsd, 3 info.dimensions.lsd, 4 info.init.lsd, 5 info.names.lsd, 6 info.stats.lsd, 7 name.check.lsd, 9 name.clean.lsd, 10 name.nice.lsd, 11 name.var.lsd, 12 Topic database LSDinterface-package, 2 read.3d.lsd, 13 read.4d.lsd, 14 read.list.lsd, 16 read.multi.lsd, 18 read.raw.lsd, 20 read.single.lsd, 21 select.colattrs.lsd, 22 select.colnames.lsd, 24 Topic datasets LSDinterface-package, 2 read.3d.lsd, 13 read.4d.lsd, 14 read.list.lsd, 16 read.multi.lsd, 18 read.raw.lsd, 20 read.single.lsd, 21 select.colattrs.lsd, 22 select.colnames.lsd, 24 Topic file info.details.lsd, 3 info.dimensions.lsd, 4 info.init.lsd, 5 info.names.lsd, 6 info.stats.lsd, 7 LSDinterface-package, 2 read.3d.lsd, 13 read.4d.lsd, 14 read.list.lsd, 16 read.multi.lsd, 18 read.raw.lsd, 20 read.single.lsd, 21 Topic interface LSDinterface-package, 2 read.3d.lsd, 13 read.4d.lsd, 14 read.list.lsd, 16 read.multi.lsd, 18 read.raw.lsd, 20 read.single.lsd, 21 Topic misc name.check.lsd, 9 name.clean.lsd, 10 name.nice.lsd, 11 name.var.lsd, 12 Topic package LSDinterface-package, 2 info.details.lsd, 3, 5 7, 23 info.dimensions.lsd, 3, 4, 6 8 info.init.lsd, 3, 5, 5, 7 info.names.lsd, 3, 5, 6, 6, 9 12 info.stats.lsd, 7 LSDinterface (LSDinterface-package), 2 LSDinterface-package, 2 make.names, 25 name.check.lsd, 9 name.clean.lsd, 10, 11, 12 name.nice.lsd, 10, 11 name.var.lsd, 10, 11, 12 read.3d.lsd, 2, 7, 8, 13, 15, 17, 19, 20, 22 read.4d.lsd, 2, 7, 8, 14, 14, 17, 19, 20, 22 read.list.lsd, 2, 14, 15, 16, 19, 20, 22 24 read.multi.lsd, 2, 14, 15, 17, 18, 20, 22 24 read.raw.lsd, 2, 14, 15, 17, 19, 20, 22 24 26

INDEX 27 read.single.lsd, 2, 14, 15, 17, 19, 20, 21, 23, 24 select.colattrs.lsd, 2, 22, 25 select.colnames.lsd, 2, 23, 24 unique, 17