Group_nstud {SchoolDataIT}R Documentation

Aggregate the students number data by class at the municipality and province level

Description

This function creates two dataframes with the number of students, classes and students by class, aggregated at the province and municipality level

Usage

Group_nstud(
  data = NULL,
  Year = 2023,
  check = TRUE,
  verbose = TRUE,
  check_registry = "Any",
  InnerAreas = TRUE,
  ord_InnerAreas = FALSE,
  check_ggplot = FALSE,
  missing_to_1 = FALSE,
  input_Registry2 = NULL,
  input_InnerAreas = NULL,
  input_Prov_shp = NULL,
  input_School2mun = NULL,
  input_AdmUnNames = NULL,
  autoAbort = FALSE,
  ...
)

Arguments

data

Either an object of class list, obtained as output of the Get_nstud function, or an object of class class tbl_df, tbl and data.frame, obtained as output of the Util_nstud_wide function, if NULL, the function will download it automatically but it will not be saved in the global environment. NULL by default.

Year

Numeric or character value. The reference school year, if either of the input_ arguments must be retrieved. Available in the formats: 2022, "2022/2023", "202223", "20222023". 2023 by default

check

Logical. If TRUE, the function runs the test of the students number availability across all school included in the school registries (see Util_Check_nstud_availability). TRUE by default

verbose

Logical. If TRUE, the user keeps track of the main underlying operations. TRUE by default.

check_registry

Character. If check == TRUE, the school registries included in the input_School2mun object (see Get_School2mun) whose availability has to be checked. Either "Registry1" (buildings section), "Registry2" (registry section), "Any" or "Both". "Any" by default.

InnerAreas

Logical. If check == TRUE, Whether it must be checked if municipalities belong to Inner areas or not. TRUE by default.

ord_InnerAreas

Logical. If check == TRUE and InnerAreas == TRUE, whether the Inner areas classification should be treated as an ordinal variable rather than as a categorical one (see Get_InnerAreas for the classification). FALSE by default.

check_ggplot

Logical. If check == TRUE, whether to display or not a static map of the availability of the students number by province; see also Util_Check_nstud_availability. TRUE by default.

missing_to_1

Logical. Only needed if data is not provided in wide format. Whether the number of classes should be imputed to 1 when it is missing; see Util_nstud_wide. FALSE by default.

input_Registry2

Object of class tbl_df, tbl and data.frame, obtained as output of the function Get_Registry If check == TRUE, the school registry from the registry section. If NULL, it will be downloaded automatically, but not saved in the global environment. NULL by default

input_InnerAreas

Object of class tbl_df, tbl and data.frame. The classification of peripheral municipalities, obtained as output of the Get_InnerAreas function. Needed only if check == TRUE and InnerAreas == TRUE. If NULL, it will be downloaded automatically, but not saved in the global environment. NULL by default

input_Prov_shp

Object of class sf, tbl_df, tbl, data.frame. The relevant shapefile of Italian municipalities, if both the check and check_ggplot options are chosen. If NULL it is downloaded automatically but not saved in the global environment. NULL by default.

input_School2mun

Object of class list with elements of class tbl_df, tbl and data.frame, obtained as output of the function Get_School2mun. The mapping from school codes to municipality (and province) codes. Needed only if 'check == TRUE'. If NULL, it will be downloaded automatically, but not saved in the global environment. NULL by default.

input_AdmUnNames

Object of class tbl_df, tbl and data.frame, obtained as output of the function Get_AdmUnNames The ISTAT file including all the codes and the names of the administrative units for the year in scope. Only needed if check == TRUE and the argument input_School2mun is NULL. If NULL, it will be downloaded automatically, but not saved in the global environment. NULL 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 to the function Util_nstud_wide if data is not provided.

Details

Numerical variables are summarised by the mean; Boolean variables are summarised by the mean as well, thus they become frequency indicators. Qualitative values, if included, are summarised by the mode. Summary measures do not include NAs.

Value

An object of class list including:

Examples

Year <- 2023

nstud23_aggr <- Group_nstud(data = example_input_nstud23, Year = Year,
                           input_Registry2 = example_input_Registry23,
                           InnerAreas = FALSE,  input_School2mun = example_School2mun23)

summary(nstud23_aggr$Municipality_data[,c(46,47,48)])

summary(nstud23_aggr$Province_data[,c(44,45,46)])



[Package SchoolDataIT version 0.1.1 Index]