R/get_nuts_ids_for_region.R

Defines functions get_nuts_ids_for_region

Documented in get_nuts_ids_for_region

#' @title NUTS IDs of a region
#' @description Return all NUTS IDs of a region of the ENTRANCES case studies.
#'
#' @param regions string or character vector, containing the name(s) of the region(s), you want to extract the NUTS IDs for.
#' @return vector with NUTS IDs
#' @export
#' @examples
#' #get NUTS IDs for a region or several regions
#' get_nuts_ids_for_region(regions="Lusatia")
#' get_nuts_ids_for_region(regions=c("Lusatia", "Central Germany", "Rhineland"))
get_nuts_ids_for_region<- function(regions){
  for (region in 1:length(regions)){
    regions[region]<-tolower(regions[region])
    regions[region]<-stringr::str_replace_all(regions, " ", "")[region]
  }
  NUTS=unique(EntrancesData$NUTS_ID[which(EntrancesData$region %in% regions & EntrancesData$NUTS_ID %in% NUTS_data$NUTS)])
  return(NUTS)
}
THartl1/EntrancesDataPackage documentation built on Dec. 18, 2021, 4:01 p.m.