diff --git a/.gitignore b/.gitignore index 0aac7c8..65c8cfe 100755 --- a/.gitignore +++ b/.gitignore @@ -2,17 +2,7 @@ .Rhistory .RData .Ruserdata -.DS_Store -inst/doc -/doc/ -/Meta/ -docs -.Renviron .Rprofile -vault -vault/secret-keys.R -gadm36_NGA_1_sp.rds -trackdown_uploads.R .RDataTmp -test.r -.Renviorn +.Renviron +.DS_Store diff --git a/inst/coverage_test-17-07_mid.rda b/inst/coverage_test-17-07_mid.rda deleted file mode 100644 index ad66218..0000000 Binary files a/inst/coverage_test-17-07_mid.rda and /dev/null differ diff --git a/man/acledR-package.Rd b/man/acledR-package.Rd index c4bbb84..995a86a 100644 --- a/man/acledR-package.Rd +++ b/man/acledR-package.Rd @@ -26,7 +26,7 @@ Authors: \itemize{ \item Lucas Fagliano \email{l.fagliano@acleddata.com} \item Trey Billing \email{t.billing@acleddata.com} - \item Rachel Goodman \email{r.goodman@acleddata.com} + \item Rachel Goodman \email{goodman.r@wustl.edu} \item Katayoun Kishi \email{k.kishi@acleddata.com} \item Michael Start \email{m.start@acleddata.com} } diff --git a/man/acled_api.Rd b/man/acled_api.Rd index d93a757..cf25ca0 100755 --- a/man/acled_api.Rd +++ b/man/acled_api.Rd @@ -61,9 +61,11 @@ This function allows users to easily request data from the ACLED API. Users can # Get all the events coded by ACLED in Argentina from 01/01/2022 until 02/01/2022 # in dyadic-wide form -argen_acled <- acled_api(email = "your_email", key = "your_key", - country = "Argentina", start_date = "2022-01-01", end_date="2022-02-01", - acled_access = FALSE) +argen_acled <- acled_api( + email = "your_email", key = "your_key", + country = "Argentina", start_date = "2022-01-01", end_date = "2022-02-01", + acled_access = FALSE +) # tibble with all the events from Argentina where each row is one event. argen_acled @@ -72,8 +74,10 @@ argen_acled # in monadic-long form using email and key saved in environment acled_access(email = "your_email", key = "your_key") -carib_acled <- acled_api(regions = "Caribbean", start_date = "2022-01-01", - end_date="2022-01-10", monadic=TRUE, acled_access = TRUE) +carib_acled <- acled_api( + regions = "Caribbean", start_date = "2022-01-01", + end_date = "2022-01-10", monadic = TRUE, acled_access = TRUE +) ## Tibble with all the events from the Caribbean where each row is one actor carib_acled diff --git a/man/acled_deletions_api.Rd b/man/acled_deletions_api.Rd index 9e7f032..3d4cfe2 100755 --- a/man/acled_deletions_api.Rd +++ b/man/acled_deletions_api.Rd @@ -34,7 +34,6 @@ This function allows users to pull deleted ACLED event IDs from the Deletions AP # Request deleted ACLED events since January 1, 2022 acled_deletions_api(date_deleted = "2022-01-01", acled_acess = TRUE) - } } \seealso{ diff --git a/man/acled_transform_interaction.Rd b/man/acled_transform_interaction.Rd index 0c7af1a..c59dc15 100644 --- a/man/acled_transform_interaction.Rd +++ b/man/acled_transform_interaction.Rd @@ -21,9 +21,11 @@ This function allows users to change from numeric interaction codes (i.e. 1, 2, \dontrun{ # Load data frame -argen_acled <- acled_api(email = "your_email", key = "your_key", - country = "Argentina", start_date = "2022-01-01", end_date="2022-02-01", - acled_access = FALSE) +argen_acled <- acled_api( + email = "your_email", key = "your_key", + country = "Argentina", start_date = "2022-01-01", end_date = "2022-02-01", + acled_access = FALSE +) # Transform the interactions argen_acled_transformed <- acled_transformation_interaction(argen_acled, only_inters = F) diff --git a/man/acled_transform_longer.Rd b/man/acled_transform_longer.Rd index c215bf3..9a35bda 100644 --- a/man/acled_transform_longer.Rd +++ b/man/acled_transform_longer.Rd @@ -25,17 +25,17 @@ Function to convert your ACLED's API calls (if dyadic) into desired monadic form } \examples{ \dontrun{ -#argen_acled <- acled_api(country = "Argentina",start_date = "2022-01-01", +# argen_acled <- acled_api(country = "Argentina",start_date = "2022-01-01", # end_date="2022-02-01", acled_access = T, prompt = F) -#argen_acled_long_actors <- acled_transform_wide_to_long(argen_acled, +# argen_acled_long_actors <- acled_transform_wide_to_long(argen_acled, # type = "full_actor") # Transforming the data -#nrow(argen_acled_long_actors) # Number of rows in the dataset -#[1] 263 # Long form +# nrow(argen_acled_long_actors) # Number of rows in the dataset +# [1] 263 # Long form -#nrow(argen_acled) ) # Number of rows in the dataset -#[1] 145 # Wide form +# nrow(argen_acled) ) # Number of rows in the dataset +# [1] 145 # Wide form } } \seealso{ diff --git a/man/acled_transform_wider.Rd b/man/acled_transform_wider.Rd index 746353a..66fe706 100644 --- a/man/acled_transform_wider.Rd +++ b/man/acled_transform_wider.Rd @@ -26,19 +26,19 @@ Function to convert your ACLED's API calls (if monadic) back into the original d } \examples{ \dontrun{ -#argen_acled <- acled_api(country = "Argentina",start_date = "2022-01-01", +# argen_acled <- acled_api(country = "Argentina",start_date = "2022-01-01", # end_date="2022-02-01", acled_access = T, prompt = F) -#argen_acled_long_actors <- acled_transform_longer(argen_acled, +# argen_acled_long_actors <- acled_transform_longer(argen_acled, # type = "full_actor") # Transforming the data to long form -#argen_acled_wide <- acled_transform_wider(argen_acled_long_actors, +# argen_acled_wide <- acled_transform_wider(argen_acled_long_actors, # type = "full_actor") # Transforming the data back to wide form -#nrow(argen_acled_wide) # Number of rows in the dataset -#[1] 145 # Wide form +# nrow(argen_acled_wide) # Number of rows in the dataset +# [1] 145 # Wide form -#nrow(argen_acled_long_actors) # Number of rows in the dataset -#[1] 263 # Long form +# nrow(argen_acled_long_actors) # Number of rows in the dataset +# [1] 263 # Long form } } \seealso{ diff --git a/man/acled_update.Rd b/man/acled_update.Rd index 8e4a092..0c54a4e 100644 --- a/man/acled_update.Rd +++ b/man/acled_update.Rd @@ -55,9 +55,10 @@ Note: The function makes new API calls to gather new and modified events. acledR::acled_access(email = "your_email", key = "your_key") new_argen_dataset <- acled_update(acledR::acled_old_dummy, - additional_countries = "Argentina", - acled_access = TRUE, - prompts = FALSE) + additional_countries = "Argentina", + acled_access = TRUE, + prompts = FALSE +) } } diff --git a/tests/testthat/test-acled_api.R b/tests/testthat/test-acled_api.R index 0535f39..fb111db 100644 --- a/tests/testthat/test-acled_api.R +++ b/tests/testthat/test-acled_api.R @@ -12,7 +12,7 @@ test_that("names of columns are correct", { ## test if event_type filters work---- test_that("event_type filters work or not",{ - expect_equal(unique(acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5", + expect_equal(unique(acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"), start_date="2022-01-01",end_date = "2022-12-31", country = "Argentina", event_type = "Protests", prompt = F, acled_access = F, log = F)$event_type), "Protests" ) @@ -29,7 +29,7 @@ test_that("country days are calculated as expected",{ mutate(t_end = lubridate::ymd("2021-01-01"), unit_test = t_end - ymd(paste0(start_year, "-01-01"))) - argentina_test_call <- acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5", + argentina_test_call <- acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"), country = "Argentina", start_date="1998-01-01", end_date = "2021-01-01",prompt = F, acled_access = F, log = T) @@ -37,27 +37,13 @@ test_that("country days are calculated as expected",{ }) -# This works locally, but fails on devtools::check() and covr::package_coverge, but not on devtools::test() and simple execution. -# local({ -# -# local_mocked_bindings(menu = function(choices,title=NULL) 2) -# -# test_that("Users can stop a call if they need to", { -# -# expect_snapshot(acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5", -# start_date="2022-01-01",end_date = "2022-12-31",countries = "Argentina", -# prompt = T, acled_access = F, log = F), error = T) -# }) -# -# }) # test on whether they can cancel - local({ local_mocked_bindings(menu = function(choices,title=NULL) 1) test_that("Users continue call", { - expect_equal(acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5", + expect_equal(acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"), start_date="2022-01-01",end_date = "2022-12-31",country = "Argentina", prompt = T, acled_access = F, log = F), acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5", start_date="2022-01-01",end_date = "2022-12-31",country = "Argentina", @@ -112,7 +98,7 @@ local({ test_that("A user can stop a call when the provided timestamp is not recognized",{ - expect_error(acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5", + expect_error(acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"), start_date="2022-01-01",end_date = "2022-12-31",country = "Argentina", timestamp = "muchachos", prompt = F, acled_access = F, log = F), regexp = "User requested") }) @@ -124,7 +110,7 @@ local({ test_that("A user can ignore the provided timestamp if it is not recognized",{ - expect_no_error(acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5", + expect_no_error(acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"), start_date="2022-01-01",end_date = "2022-12-31",country = "Argentina", timestamp = "muchachos", prompt = F, acled_access = F, log = F)) }) @@ -171,12 +157,12 @@ test_that("Population columns are being received", { ## Error when someone requests a region that does not exist---- test_that("Error prompted when region does not exist", { - expect_error(acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5",regions = "Narnia", + expect_error(acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"),regions = "Narnia", start_date="2022-01-01",end_date = "2022-12-31",prompt = F, acled_access = F, log = F), regexp = "One or more requested region names not in the ACLED country list.") }) test_that("Error when region number does not exist", { - expect_error(acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5",regions = 420, + expect_error(acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"),regions = 420, start_date="2022-01-01",end_date = "2022-12-31",prompt = F, acled_access = F, log = F), regexp = "One or more requested region numbers not in the ACLED country list") }) @@ -184,7 +170,7 @@ test_that("Error when region number does not exist", { ## Errors when a country requested doesnt exists ---- test_that("Error when one of two countries are wrong",{ - expect_error(acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5",country = c("Argentia","Bolivia"), + expect_error(acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"),country = c("Argentia","Bolivia"), start_date="2022-01-01",end_date = "2022-12-31",prompt = F, acled_access = F, log = F), regexp = "One or more of the requested *")}) @@ -206,7 +192,7 @@ test_that("acled_api() throws an error when called with invalid arguments", { "Country is not a valid option. Please utilize \"country\", without capitalizing") - expect_error(acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5", + expect_error(acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"), Region = "North America", start_date="2022-01-01", end_date = "2022-12-31", @@ -215,7 +201,7 @@ test_that("acled_api() throws an error when called with invalid arguments", { log = F), regexp= "Region is not a valid option. Please utilize \"regions\"") - expect_error(acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5", + expect_error(acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"), Regions = "North America", start_date="2022-01-01", end_date = "2022-12-31", @@ -272,7 +258,7 @@ test_that("Users gets an error when acled_access is False, but no key or email a # Test error if start_date is after end_date ---- test_that("start_date is after end_date", { expect_error( - acled_api(email = "acledexamples@gmail.com", key = "M3PWwg3DIdhHMuDiilp5", + acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"), country = "Argentina", start_date="2022-01-01", end_date = "2021-01-01",