rtGetFromRecord: to access population data from a record array...

Description Usage Arguments Value Examples

Description

rtGetFromRecord allows access to population data from a grid of sexes and ages. You can specify which [days,y,x,sex,age] you want to get data for. Each variable defaults to 'all' so rtGetFromRecord(aRecord) would return the whole grid. ='sum' can be used to sum across dimensions, thus rtGetFromRecord(aRecord,x='sum',y='sum',sex='sum',age='sum') would produce a single value of the total population on the grid.

Usage

1
2
3
rtGetFromRecord(aRecord, days = "all", x = "all", y = "all",
  sex = "all", age = "all", ageSum = "sum", drop = TRUE,
  verbose = FALSE)

Arguments

aRecord

an array with the age distributions of males & females [y,x,sex,age]

days

day of the simulation starting at 1 options 'all', 'sum', a number >0 and <days in the simulation, or a series e.g. c(1,2) or c(4:7)

x

grid column number

y

grid row number

sex

'all' returns both sexes separately,'M','F', 'sum' sums sexes

age

'all' returns age distribution, 'sum' sums all ages, or an integer age or an age range too, e.g. c(2:3)

ageSum

if='sum'(default) sums ages when age=a range, otherwise returns ages separately

drop

whether to drop dimensions that just have a single value, TRUE as default

verbose

print what it's doing T/F

Value

an array, matrix or vector named with remaining dimensions of [y,x,sex,age]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
aRecord <- rt_runGridTestSpread()
aGrid <- rtGetFromRecord(aRecord,days=2) #gives raw array for one day
rtGetFromRecord(aRecord,days=2,x='sum',y='sum',sex='sum') #age structure for whole pop
rtGetFromRecord(aRecord,days=2,x='sum',y='sum',age='sum') #sex ratio for whole pop
#slight anomally this gives 2 grids for M&F
rtGetFromRecord(aRecord,days=2,x='all',y='all',age=c(1,2),sex='all')
#this gives 4 grids for M&F age 1&2
rtGetFromRecord(aRecord,days=2,x='all',y='all',age=c(1,2),sex='all',ageSum='other')
#this gives just 1 grid summed across all, currently tricky to sum by sex but not by age
rtGetFromRecord(aRecord,days=2,x='all',y='all',age=c(1,2),sex='sum')
#new test case
aRecord <- rt_runGridTestSpread(3,3,iDays=4)
rtGetFromRecord(aRecord,days=1:3,x='all',y='all',age=c(1,2),sex='sum')
#to subset days for a specified cell, do this
#tst2 <- rtGetFromRecord(aRecord,x=2,y=2,sex='sum',age='sum',days=c(1:3))
#plot(tst2,type='l')

AndySouth/rtsetse documentation built on May 5, 2019, 6:02 a.m.