Skip to content

Commit

Permalink
Merge pull request #45 from panukatan/dev
Browse files Browse the repository at this point in the history
add utility unexported function for report download
  • Loading branch information
ernestguevarra authored Jul 27, 2024
2 parents 0b04d9e + b94b398 commit 28f412e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* added CRAN DOI badge
* added 2021 typhoon data
* added utility unexported function to download cyclone reports


# bagyo 0.1.1
Expand Down
9 changes: 9 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Download PAGASA cyclone reports ----------------------------------------------

pagasa_download_cyclone_reports <- function(url, destfile) {
if (!destfile %in% list.files("data-raw", full.names = TRUE)) {
utils::download.file(url = url, destfile = destfile)
destfile
} else
destfile
}
3 changes: 2 additions & 1 deletion data-raw/process_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ urls <- paste0(
2017:2021, ".pdf"
)


Map(
f = download.file,
f = pagasa_download_cyclone_reports,
url = as.list(urls),
destfile = as.list(
paste0("data-raw/", 2017:2021, ".pdf")
Expand Down

0 comments on commit 28f412e

Please sign in to comment.