Skip to content

Commit

Permalink
improve tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
evaaepelde committed Sep 23, 2024
1 parent c7dbca1 commit 0b8d8b4
Show file tree
Hide file tree
Showing 10 changed files with 252 additions and 69 deletions.
26 changes: 20 additions & 6 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,16 @@ calc_ep <- function(year, index = "all"){
year <- as.numeric(year)
}

if (!year %in% seq(2006,2021,1)) {
stop(sprintf('You introduced year %s which is not available. Possible options are %s.',
year, paste(seq(2006,2021,1), collapse = ", ")))
wrong_years <- year[!year %in% seq(2006,2021,1)]

if (length(wrong_years) != 0) {
if(length(wrong_years) == 1){
stop(sprintf('You introduced year %s which is not available. Possible options are %s.',
paste0(wrong_years, collapse = ", "), paste(seq(2006,2021,1), collapse = ", ")))
}else{
stop(sprintf('You introduced years %s which are not available. Possible options are %s.',
paste0(wrong_years, collapse = ", "), paste(seq(2006,2021,1), collapse = ", ")))
}
}

accepted <- c("all",
Expand Down Expand Up @@ -283,9 +290,16 @@ calc_tp <- function(year, index = "all"){
year <- as.numeric(year)
}

if (!year %in% seq(2006,2021,1)) {
stop(sprintf('You introduced year %s which is not available. Possible options are %s.',
year, paste(seq(2006,2021,1), collapse = ", ")))
wrong_years <- year[!year %in% seq(2006,2021,1)]

if (length(wrong_years) != 0) {
if(length(wrong_years) == 1){
stop(sprintf('You introduced year %s which is not available. Possible options are %s.',
paste0(wrong_years, collapse = ", "), paste(seq(2006,2021,1), collapse = ", ")))
}else{
stop(sprintf('You introduced years %s which are not available. Possible options are %s.',
paste0(wrong_years, collapse = ", "), paste(seq(2006,2021,1), collapse = ", ")))
}
}

accepted <- c("all",
Expand Down
60 changes: 31 additions & 29 deletions docs/articles/Tutorials.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ articles:
Tutorials: Tutorials.html
TutorialsEnergyPoverty: TutorialsEnergyPoverty.html
TutorialsTransportPoverty: TutorialsTransportPoverty.html
last_built: 2024-09-18T14:47Z
last_built: 2024-09-23T10:05Z
2 changes: 1 addition & 1 deletion docs/reference/calc_ep.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/calc_tp.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0b8d8b4

Please sign in to comment.