resTabDemog: Create summary for population scenarios in Table 1.

Description Usage Arguments Details Value Examples

View source: R/resTabDemog.R

Description

Used in Table 1, Supplemental Tables. Generates dataframe with summaries of population projections.

Usage

1
resTabDemog(ldemog = NA, make_html = FALSE)

Arguments

ldemog

List with population projections from "PopScen.R"

make_html

Logical (TRUE/FALSE). Should html tables be written.

Details

Title

Value

Data.frame with summaries of population projections for three scenarios.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## Not run: 
#1) River length coverage
lsf <- prepTabcover(pBasin = B, pBasinSp = Bsp, 
pBasinC = BC, riv = rin, rastAc = ras1, make_shape = FALSE)
rp <- system.file("shape/shapes_rivers3395", package="cmartr")
lt <- resTab(listsf = lsf, input_rp = rp, make_html = FALSE)
atest <- lt$rlcb
# add key and make sure all levels are represented
atest$namekey <- paste(atest$BASIN_N, atest$name, atest$subbasn, sep = "_")
riverl <- expand.grid(namekey = unique(atest$namekey), 
                     accessible = unique(atest$accessible) )
riverl <- merge(riverl, atest, all.x=TRUE)
selNA <- which(is.na(riverl$tot_km))
coln <- c("tot_km", "tot_notPA", "tot_PA", "tot_Ind", "tot_SP", "tot_use")
riverl[selNA, coln)] <- 0

#2) Data frame with population parameters created from "PopParam.R" 
dfpop <- readRDS("inst/other/dfpop.RDS") 

#3) Create list with population parameters for different scenarios
# across river lengths per geographic/political coverage class: 
# basin, country, subbasin, accessible, protected area...
l.gpop <- plyr::dlply(dfpop, c("akey"), PopPrep, riverl=riverl)

#4) Project scenarios across species range
# takes 5 hours and writes 10 GB of results.
# Do not run unless you really want to.....
dflup <- plyr::ldply(l.gpop, PopProj, write_csv = TRUE, 
write_db = FALSE)

#5) Get results from 3 scenarios
lscen <- PopScen(dflup)

#6) Produce summary tables.
dfsum <- resTabDemog(ldemog = lscen, make_html = FALSE)

## End(Not run)

darrennorris/cmartr documentation built on May 23, 2020, 10:10 p.m.