ref_dbR Documentation

TODO: this function will replace ref_users... Statistics about Arches project: users, counts by resource models, etc.

Description

statistics about Arches records: users (total number, activities, etc.), resource models (total numbers, etc.)

Usage

ref_db(
  db.con = NA,
  d = NA,
  db.name = "EAMENA",
  identifiernode = "E42_Identifier",
  stat = c("all"),
  chart.type = c("all"),
  stat.name = NA,
  plot.g = F,
  export.plot.g = F,
  dirOut = paste0(system.file(package = "eamenaR"), "/results/"),
  date.after = NA,
  date.before = Sys.Date(),
  fig.width = 8,
  fig.height = 8,
  verbose = TRUE
)

Arguments

db.con

the parameters for the PostgreSQL EAMENA DB, in a 'RPostgres::dbConnect()' format.

d

a hash() object (a Python-like dictionary).

db.name

the name of the Arches database, by default 'EAMENA'.

stat

the type of statistic that will be computed. This is also the hash dictionary ('d') field name that will be filled with this statistics, e.g. "users", "date_joined", etc., or "all". Default: "all".

chart.type

the type of stat chart, or diagram that will be plotted. Choice: "edtf" for cumulative function, etc. Default "all".

stat.name

the name of the output file. If NA (default) will use the 'stat' variable.

plot.g

if TRUE will create a plot. Default: FALSE.

export.plot.g

if TRUE will export the plot. Default: FALSE.

dirOut

the folder where the outputs will be saved. By default: '/results'. If it doesn't exist, it will be created. Only useful is export.plot.g is TRUE.

date.after

the date after which the calculation is made. Useful to limit the analysis. Default: NA.

date.before

the date before which the calculation is made. Useful to limit the analysis. Default, the current date ('Sys.Date()')

fig.width, fig.height

dimension of the exported plot in cm.

verbose

if TRUE (by default), print messages

Value

a hash() object. If plot.g and export.plot.g are set to TRUE will also create and save plots

Examples


d <- hash::hash()
my_con <- RPostgres::dbConnect(drv = RPostgres::Postgres(),
                               user = 'xxx',
                               password = 'xxx',
                               dbname = 'eamena',
                               host = 'ec2-54-155-109-226.eu-west-1.compute.amazonaws.com',
                               port = 5432)
d <- ref_db(db.con = my_con,
               d = d,
               date.after = "2020-08-01",
               plot.g = T,
               export.plot.g = T,
               fig.width = 14)