Map_DB {SchoolDataIT}R Documentation

Map school data

Description

This function displays a map of the data arranged trough the function Set_DB. It supports two kinds of map:

The user must select a variable to display. It is possible to insert either a readily-downloaded database obtained through the function Set_DB or the basic inputs to plug in that function, other than an input shapefile. Relevant arguments not provided by the user will be download automatically, but not saved into the global environment. However we suggest to plug in at least some inputs, as otherwise the running time may be long. This function generalises the functionalities of the more data-specific functions Map_School_Buildings and Map_Invalsi.

Usage

Map_DB(
  data = NULL,
  Year = 2023,
  field,
  level = "LAU",
  plot = "mapview",
  popup_height = 200,
  col_rev = FALSE,
  pal = "Blues",
  input_shp = NULL,
  region_code = c(1:20),
  main_pos = "top",
  main = "",
  order = NULL,
  autoAbort = FALSE,
  ...
)

Arguments

data

Object of class tbl.df, tbl and data.frame, obtained as output of the Set_DB function. If NULL, it will be arranged automatically but not saved into the global environment. NULL by default.

Year

Numeric or Character. The reference school year, needed if either data or input_shp are not provided. Available in the formats: 2023, "2022/2023", 202223, 20222023. 2023 by default.

field

Character. The variable to display in the map.

level

Character. The administrative level of detailed at which the target variable must be displayed. Either "LAU"/"Municipality" or "NUTS-3"/"Province". If the "data" argument is plugged in, please select the same level. "LAU" by default.

plot

Character. The type of map to display; either "mapview" for interactive maps, or "ggplot" for static maps. "mapview" by default.

popup_height

Numeric. The height of the popup table in terms of pixels if the "mapview" mode is chosen. 200 by default.

col_rev

Logical. Whether the scale of the colour palette should be reverted or not. FALSE by default.

pal

Character. The palette to use if the "mapview" mode is chose. "Blues" by default.

input_shp

Object of class sf, tbl.df, tbl and data.frame. The relevant shapefiles of Italian administrative boundaries, at the selected level of detail (LAU or NUTS-3). If NULL, it is downloaded automatically but not saved in the global environment. NULL by default.

region_code

Numeric. The NUTS-2 codes of the units that must be displayed. If the level is set to "LAU", choosing a limited number of regions is recommended. By default, c(1,3,5:20), i.e. all Italian regions except the provinces of Aosta, Trento and Bozen which have data availability issues.

main_pos

Character.Where the header should be placed if the ggplot mode is chosen. The header is located on the top if "top" is given as input, and above the legend scale otherwise. "top" by default.

main

Character. The title to display in the "ggplot" rendering options.

order

Character. The educational level. Either "Primary" (primary school), "Middle" (middle school), or "High" (high school). If the data include the Invalsi census survey, please select a level consistent with the chosen educational grade. "Media" by default.

autoAbort

Logical. In case any data must be retrieved, whether to automatically abort the operation and return NULL in case of missing internet connection or server response errors. FALSE by default.

...

Additional arguments for the input database, if not provided; see Set_DB

Value

If plot == "mapview", an object of class mapview. Otherwise, if plot == "ggplot", an object of class gg and ggplot.

Examples




DB23 <- Set_DB(Year = 2023, level = "NUTS-3",
       Invalsi_grade = c(10,13), NA_autoRM = TRUE,
       input_Invalsi_IS = example_Invalsi23_prov, input_nstud = example_input_nstud23,
       input_InnerAreas = example_InnerAreas,
       input_School2mun = example_School2mun23,
       input_AdmUnNames = example_AdmUnNames20220630,
       nteachers = FALSE, BroadBand = FALSE, SchoolBuildings = FALSE)




Map_DB(DB23, field = "Students_per_class_13", input_shp = example_Prov22_shp, level = "NUTS-3",
 col_rev = TRUE, plot = "ggplot")

Map_DB(DB23, field = "Inner_area", input_shp = example_Prov22_shp, order = "High",
 level = "NUTS-3",col_rev = TRUE, plot = "ggplot")

Map_DB(DB23, field = "M_Mathematics_10", input_shp = example_Prov22_shp, level = "NUTS-3",
 plot = "ggplot")



[Package SchoolDataIT version 0.2.0 Index]