knitr::opts_chunk$set(echo = TRUE)

Platform file

Platform file describe characteristics of a given InfluenzaNet platform :

It is just a R script with a list of variables or function calls.

This file has to be stored in a directory (which can contains several platform definitions) and location is defined with platform.path package options (see introduction vignette). The name of this file define the platform id (code of the country for example).

Contents

Global options : to be defined with platform_options() function in the platform file

survey_default_language

Define the code of the language to use by default in i18n files.

survey_use_channel

boolean. If TRUE by default survey response will be loaded only for empty channel. If FALSE, channel column will be ignored.

first.season.censored (optional)

boolean value. if TRUE the first season of each participant need to be left censored (we dont have data before)

get_first_season_country function(country)

function with one parameter country. Should return the first available season year for the country. This is needed when first.season.censored is active (TRUE) to

health.status (optional)

If the data storage model is using a single table for each survey, you have to describe the table (or view) containing health status computed from each weekly survey

health.status = list(
 default="health_status_view" # Table name containing health status for each survey
 id="weekly_id" # Name of the column containg the corresponding response id in the weekly's data response table. 
)

complete.intake

list() of parameters to be used to define the intake completion strategy

Example

platform_options(
  first.season.censored=FALSE
)

Survey registration

Each survey has to be registered to the package before the surveys_* functions can be used. Registration is done by calling the function platform_define_survey() (usually in the platform file to be available in all the scripts, but it's possible to register a new survey in a script).

The survey definition is described in the survey definition section

Survey History

InfluenzaNet is collecting data during specific time period each year, mainly during a wide winter season (classically november to april). Use the platform_season_history() function to describe each season.

This function accept several parameters : - season : the season number (this is the year number of the starting year of the season, e.g. 2010 for 2010-2011 season, 2017 for 2017-2018 season ) - dates : list(start, end) starting and ending dates for the season - weekly: name of the weekly table for this season (if not single data table model) - intake: name of the intake table for this season (if not single data table model) - health: name of the view containing health status for this season, used by survey_load_health_status()function

# Season 2011 is from 2011 10 of November to 2012, 22 of April
# This single table model, if single.table=TRUE in survey definition you dont have to indicate table names
platform_season_history(2011, dates=list(start="2011-11-10", end="2012-04-22"))

# Other platform
# Using a by season table model, for each season we need to indicate what is the table name to use to get the data
# (here we have created view to have more convenient table name )
# You can add extra parameter for the season, here `year.pop` indicating the year of the population to use 
platform_season_history(
  season ='2014',
  weekly='pollster_results_weekly_2014',
  intake='pollster_results_intake_2014',
  health='pollster_health_status_2014',
  dates=list('start'='2014-11-19','end'='2015-04-20'),
  year.pop=2013
)

Geographic tables

platform_geographic_levels()

describes available geographic levels and how they are organized (hierarchies)

# Describe geographic levels names and hierarchy 
# Here zip < nuts3 < nuts2 < country
# The lowest level is zip
# Table describing all level mappings from zip level is "geo_zip"
# And each column with the corresponding level is described
# Hierarchy of levels can also be describe
# "country" option will indicate we must specify country with the level
platform_geographic_levels(
  geo.levels = c('zip', 'nuts3', 'nuts2', 'nuts1', 'country'),
  # level code of the information in the survey
  level.base = 'zip',
  table = 'geo_zip',
  columns =  c(
    'zip'='code_zip',
    'nuts3'='code_nuts3',
    'nuts2'='code_nuts2',
    'nuts1'='code_nuts1',
    'country'='country'
  ),
  hierarchies=list(
    'europe'=c('zip', 'nuts3', 'nuts2', 'nuts1', 'country')
  ),
  country = TRUE,
  default.hierarchy="europe"
)

platform_geographic_tables

Allows to describe for each level the name of the table containing all area in the level and the name of the columns. By using this function you inform the package on how your database is organized. This function is needed to use geographic function and to be able to load the data about geographic levels

# Example of geographic tables describing each levels and their areas
# For european database (we include a "country" level, which is not needed for a country specific platform database)
platform_geographic_tables(
   list(
     'zip'=list(table='geo_zip', title=NULL, column='code_zip'),
     'nuts3'=list(table='geo_nuts3', title="title", column='code_nuts3'),
     'nuts2'=list(table='geo_nuts2', title="title", column='code_nuts2'),
     'nuts1'=list(table='geo_nuts1', title="title", column='code_nuts1'),
     'country'=list(table='geo_country', title="title", column='country')
  )
)


cturbelin/ifnBase documentation built on Nov. 5, 2023, 12:54 p.m.