make.table: Make a table from HexSimR results

Description Usage Arguments Details Value See Also

View source: R/make.tables.R

Description

make.table reads the result files generated by HexSimR and compiles a table after having rounded the decimal digits.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
make.table(
  path.results = NULL,
  scenarios = "all",
  fnames,
  SSMD = FALSE,
  colh = list(c("GroupSize", "Resources", "nGroups", "ha", "sqkm")),
  vround = 1,
  sdround = 1,
  time.steps = NULL,
  table.name = "Tables.xlsx",
  tab.name = NULL,
  save2disk = TRUE,
  dir.out = NULL
)

Arguments

path.results

The path to the 'Results' folder

scenarios

A character vector with the scenarios to be processed or "all"

fnames

The name(s) of the output file(s) to be processed. If more the one scenario is passed, the output file names have to be all equal

SSMD

Whether the data being processed are SSMD comparisons (default: FALSE)

colh

A list with as many elements as the length of fnames. Each element is a character vector with the names of the column headings to be considered for the relative fnames (default: ranges' headings)

vround

The number of digits the variable (e.g. the mean, the p-values) should be rounded to

sdround

If SSMD=FALSE, the number of digits the standard deviation should be rounded to

time.steps

A numeric vector with the time steps to include. If NULL (default), all time steps are included. See details for more information

table.name

The name of the file where to save the table

tab.name

The name of the tab to be saved in the xls file. By default, "Descriptive" or "SSMD", depending on whether SSMD=FALSE or SSMD=TRUE respectively.

save2disk

Whether to save to disk the table

dir.out

The directory where to save the table. If NULL (default), the file will be written in the 'Results' folder

Details

make.table can process either descriptive statistics (generated using collate.census, ranges or move) or statistical comparisons generated using SSMD.census, SSMD.ranges or SSMD.move), but only one type of result in any one time. For each run of make.table a sheet is created as output in a .xls file. If the name of the xls file is kept equal, the new sheet is added to the existing file. ATTENTION: If the name of the new sheet is the same of an existing one, the data will be pasted over in the existing sheet, possibly making the results incomprehensible.

When processing census data, several files can be passed at once by passing a character vector of length > 1 to fnames. Note that the extension (.csv) of the file is used to identify whether it was requested to process descriptive statistics generated by movement reports. If you have changed the extensions of the result files, this function may have impredictable results.

When more than one scenario is processed, then make.table assumes that, within each scenario, the result file name is the same. The only exception is when processing the descriptive statistics of census data. In this case, the name of scenario is automatically added to the suffix. In these cases, the suffix of the files has to be passed to fnames (i.e. "[ncensus].all.xlsx", where "ncensus" is the number of the census event, and ".comb.xlsx" is the standard suffix that HexSimR adds to all files generated with collate.census.

colh is used to pass the headings of the columns to be processed. It MUST be passed as a list, with an element for each file that was passed with fnames.

If SSMD=TRUE and scenarios="all", R may throw an error because the base scenario is included in scenarios (unless it was manually removed) but it is not present in the result file. When SSMD=TRUE a character vector has to be passed to scenarios.

When SSMD=TRUE, currently, only p-values are reported in the table.

Note that when SSMD=TRUE, and the function is pointed to a SSMD comparison of ranges report statistics, the appropriate setting for the time step is time.steps=NULL (default) because these are already subsetted when the SSMD comparison is done, unless all time steps were kept when calling ranges or multi.reports. Also, when this function is used to summarise descriptive statistics from ranges or movement data, this argument must be NULL because there are no time steps in these outputs.

By default, the sheet in the xls file takes name "Descriptive" or "SSMD", depending on whether SSMD=FALSE or SSMD=TRUE respectively. This behaviour can be altered by passing a character vector to tab.name.

Value

A data.frame (data.table) with the compiled table. If save2disk=TRUE an xls file is also saved to disk.

See Also

collate.census, ranges, move, SSMD.census, SSMD.ranges, SSMD.move


carlopacioni/HexSimR documentation built on Nov. 28, 2020, 4:12 p.m.