# get the list of file names of example LSD results
files <- list.files.lsd( system.file( "extdata", package = "LSDinterface" ) )
# read first instance of all variables from files (one level each),
# pasting the directory where the example files are (not required if in working dir)
inst1Array <- read.3d.lsd( files )
print( inst1Array[ 5 : 10, 1 : 7, 1 ] )
print( inst1Array[ 5 : 10, 1 : 7, 2 ] )
print( inst1Array[ 5 : 10, 1 : 7, 3 ] )
# read first instance of a set of variables named _A1p and _growth1
ab1Array <- read.3d.lsd( files, c( "_A1p", "_growth1" ) )
print( ab1Array[ 20 : 25, , 1 ] )
print( ab1Array[ 20 : 25, , 2 ] )
print( ab1Array[ 20 : 25, , 3 ] )
# read instance 2 of all variables, skipping the initial 20 time steps
# and keeping up to 30 time steps (from t = 21 up to t = 30)
inst2Array21_30 <- read.3d.lsd( files, skip = 20, nrows = 30, instance = 2 )
print( inst2Array21_30[ , , "Sim1_1" ] ) # use the file name to retrieve
print( inst2Array21_30[ , , "Sim1_2" ] )
# read instance 5 of all variables in second-level objects, using up to 2 cores
inst5array2 <- read.3d.lsd( files, instance = 2, posit = "*_*",
posit.match = "glob", nnodes = 2 )
print( inst5array2[ 11 : 20, , 1 ] )
Run the code above in your browser using DataLab