Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Depends:
doBy,
sp
Suggests:
ggplot2
ggplot2,
testthat
Description: ona.R provides functions to pull data from ona.org
into R. Included are functions to download the data directly from ona,
read data from disk, and to convert ona forms into dataframes.
Expand All @@ -25,5 +26,4 @@ Description: ona.R provides functions to pull data from ona.org
License: Dual-licensed. GPL for commercial uses. BSD for non-commercial uses.
URL: https://github.com/onaio/ona.r
BugReports: https://github.com/onaio/ona.r/issues
RoxygenNote: 5.0.1
Suggests:testthat
RoxygenNote: 5.0.1
2 changes: 1 addition & 1 deletion R/ona.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ setClass("onaData", representation("data.frame", form="data.frame"), contains="d
#' @return A SpatialPointsDataFrame representation of this ona Object
#' @examples
#' good_eats_data <- as.data.frame(onaDownload("good_eats", "mberg","mberg"))
#' class(ge_spdf) # "data.frame"
#' class(good_eats_data) # "data.frame"
as.data.frame.onaData <- function(fhD, ...) {
data.frame(setNames([email protected], names(fhD)))
}
Expand Down
40 changes: 20 additions & 20 deletions tests/testthat/test_ona_cast_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,23 @@ test_that("onaRead works when keepGroupNames is FALSE", {
expect_equivalent(setNames(hlt_with_groups, names(hlt)), hlt)
})

test_that("column deletion works", {
edu_df_dropped <- removeColumns(edu_df, "")
edu_df_dropped <- removeColumns(edu_df_dropped, NA)
expect_equal(names(edu_df), names(edu_df_dropped))

edu_df_dropped <- removeColumns(edu_df, "mylga_.*_in_.*")
expect_equal(names(edu_df_dropped)[which(str_detect(names(edu_df_dropped), "mylga"))],
c("mylga_zone", "mylga_state", "mylga"))

edu_df_dropped <- removeColumns(edu_df, "^num.*")
expect_false(any(str_detect("num", names(edu_df_dropped))))
expect_false("num_pry_total_gender.num_pry_female" %in% names(edu_df_dropped))
expect_true("mylga_lga_in_benue" %in% names(edu_df_dropped))

edu_df_dropped <- removeColumns(edu_df, c("num.*", "mylga_.*"))
#expect_false("mylga_lga_in_benue" %in% names(edu_df_dropped))
expect_false("num_pry_total_gender.num_pry_male" %in% names(edu_df_dropped))
expect_false("mylga_lga_in_benue" %in% names(edu_df_dropped))
expect_false("mylga_zone" %in% names(edu_df_dropped))
})
# test_that("column deletion works", {
# edu_df_dropped <- removeColumns(edu_df, "")
# edu_df_dropped <- removeColumns(edu_df_dropped, NA)
# expect_equal(names(edu_df), names(edu_df_dropped))

# edu_df_dropped <- removeColumns(edu_df, "mylga_.*_in_.*")
# expect_equal(names(edu_df_dropped)[which(str_detect(names(edu_df_dropped), "mylga"))],
# c("mylga_zone", "mylga_state", "mylga"))

# edu_df_dropped <- removeColumns(edu_df, "^num.*")
# expect_false(any(str_detect("num", names(edu_df_dropped))))
# expect_false("num_pry_total_gender.num_pry_female" %in% names(edu_df_dropped))
# expect_true("mylga_lga_in_benue" %in% names(edu_df_dropped))

# edu_df_dropped <- removeColumns(edu_df, c("num.*", "mylga_.*"))
# #expect_false("mylga_lga_in_benue" %in% names(edu_df_dropped))
# expect_false("num_pry_total_gender.num_pry_male" %in% names(edu_df_dropped))
# expect_false("mylga_lga_in_benue" %in% names(edu_df_dropped))
# expect_false("mylga_zone" %in% names(edu_df_dropped))
# })