Skip to content

Commit

Permalink
adding further functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyclements committed Jun 14, 2024
1 parent 5870d03 commit 2474219
Show file tree
Hide file tree
Showing 6 changed files with 1,584 additions and 59 deletions.
931 changes: 889 additions & 42 deletions R/data_sheet.R

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions R/is_climatic_element.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#' Is Climatic Element
#' @description
#' Check if the column name is a climatic element.
#'
#' @param x Character, the name of the column.
#'
#' @return Logical, TRUE if the column is a climatic element, FALSE otherwise.
is_climatic_element = function(x) {
return(x %in% c(rain_label, rain_day_label, rain_day_lag_label, temp_min_label, temp_max_label, temp_air_label,
temp_range_label, wet_buld_label, dry_bulb_label, evaporation_label, capacity_label, wind_speed_label,
wind_direction_label, sunshine_hours_label, radiation_label, cloud_cover_label))
}
41 changes: 41 additions & 0 deletions R/standardise_country_names.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#' Standardise Country Names
#' @description
#' Standardise country names in the dataset.
#'
#' @param country Name of Country
#'
#' @return Name of country
standardise_country_names = function(country) {
country_names <- country
country_names[country_names == "Antigua and Bar"] <- "Antigua and Barbuda"
country_names[country_names == "Bosnia and Herz"] <- "Bosnia and Herzegovina"
country_names[country_names == "Cabo Verde"] <- "Cape Verde"
country_names[country_names == "Central African"] <- "Central African Republic"
country_names[country_names == "Cote d'Ivoire"] <- "Cote d'Ivoire"
country_names[country_names == "Congo, Democrat"] <- "Democratic Republic of the Congo"
country_names[country_names == "Dominican Repub"] <- "Dominican Republic"
country_names[country_names == "Egypt, Arab Rep"] <- "Egypt"
country_names[country_names == "Equatorial Guin"] <- "Equatorial Guinea"
country_names[country_names == "Gambia, The"] <- "Gambia"
country_names[country_names == "Iran, Islamic R"] <- "Iran, Islamic Republic of"
country_names[country_names == "Korea, Republic"] <- "Korea, Republic of"
country_names[country_names == "Kyrgyz Republic"] <- "Kyrgyzstan"
country_names[country_names == "Lao People's De"] <- "Lao People's Democratic Republic"
country_names[country_names == "Macedonia, form"] <- "Macedonia, the Former Yugoslav Republic of"
country_names[country_names == "Moldova"] <- "Moldova, Republic of"
country_names[country_names == "Papua New Guine"] <- "Papua New Guinea"
country_names[country_names == "Russian Federat"] <- "Russian Federation"
country_names[country_names == "St. Kitts and N"] <- "Saint Kitts and Nevis"
country_names[country_names == "St. Lucia"] <- "Saint Lucia"
country_names[country_names == "St. Vincent and"] <- "Saint Vincent and the Grenadines"
country_names[country_names == "Sao Tome and Pr"] <- "Sao Tome and Principe"
country_names[country_names == "Slovak Republic"] <- "Slovakia"
country_names[country_names == "Syrian Arab Rep"] <- "Syrian Arab Republic"
country_names[country_names == "Trinidad and To"] <- "Trinidad and Tobago"
country_names[country_names == "Tanzania"] <- "United Republic of Tanzania"
country_names[country_names == "Venezuela, Repu"] <- "Venezuela"
country_names[country_names == "Vietnam"] <- "Viet Nam"
country_names[country_names == "West Bank and G"] <- "West Bank and Gaza"
country_names[country_names == "Yemen, Republic"] <- "Yemen"
return(country_names)
}
Loading

0 comments on commit 2474219

Please sign in to comment.