Skip to content

Commit

Permalink
refactor: renamed some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
asiripanich committed Jan 14, 2020
1 parent 43e01b2 commit a5a014c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export(abs_read_tb)
export(tb_distribute_not_stated)
export(tb_range)
export(tb_remove_overseas_visitors)
export(tb_remove_row_where)
export(tb_remove_row_with)
export(tb_remove_rows_where)
export(tb_remove_rows_with)
export(tb_remove_totals)
export(tb_simplify_names)
import(data.table)
Expand Down
18 changes: 3 additions & 15 deletions R/tb-tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,14 @@ tb_range <- function(x) {
x
}

#' remove overseas visitors
#'
#' @param x data.frame
#'
#' @return data.frame
#' @export
tb_remove_overseas_visitors <- function(x) {
checkmate::assert_data_frame(x, null.ok = FALSE)
x <- x[rowSums(x == "Overseas visitor") == 0]
return(x)
}

#' remove rows with 'value'
#'
#' @param x data.frame
#' @param value a vector
#'
#' @return data.frame
#' @export
tb_remove_row_with <- function(x, value) {
tb_remove_rows_with <- function(x, value) {
checkmate::assert_data_frame(x, null.ok = FALSE)
if (!is.data.table(x))
x <- as.data.table(x)
Expand All @@ -86,9 +74,9 @@ tb_remove_row_with <- function(x, value) {
#' @export
#'
#' @examples
tb_remove_row_where <- function(x, var, value) {
tb_remove_rows_where <- function(x, var, value) {
checkmate::assert_data_frame(x, null.ok = FALSE)
if (!x %has_name% var)
if (!checkmate::test_names(names(x), must.include = var))
return(x)
if (!is.data.table(x))
x <- as.data.table(x)
Expand Down
6 changes: 3 additions & 3 deletions man/tb_remove_row_where.Rd → man/tb_remove_rows_where.Rd

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

6 changes: 3 additions & 3 deletions man/tb_remove_row_with.Rd → man/tb_remove_rows_with.Rd

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

0 comments on commit a5a014c

Please sign in to comment.