R/get_data_for_variable_and_region.R

Defines functions get_data_for_variable_and_region

Documented in get_data_for_variable_and_region

#' @title Extracts data for a specific variable and specific NUTS IDs from a data set.
#' @description Extracts data for specific regional IDs (e.g. NUTS IDs) and a specific variable from a data set. Default is the Entrances data set.
#'
#' @param VarName character string or vector with character strings with the name(s) of the variable(s).
#' @param RegionIDs vector with character strings of the regional IDs, e.g. NUTS IDs, LAU IDs
#' @param data dataframe, from which you want to extract your data. The data frame must contain a column called variable and the regional IDs in the first column. Default is the EntrancesData data set.
#' @return dataframe
#' @export
#' @examples
#' #extracts data for specific NUTS IDs and a specific variable from a data frame. Default is the EntrancesData data set.
#' get_data_for_variable_and_region(VarName="GDP_EUR", RegionIDs=c("ITG2C","ITG2B"), data=EntrancesData)
get_data_for_variable_and_region<- function(VarName, RegionIDs, data=EntrancesData){
  dataout<-data[which(data$variable %in% VarName & data[,1] %in%  RegionIDs),]
  return(dataout)
}
THartl1/EntrancesDataPackage documentation built on Dec. 18, 2021, 4:01 p.m.