Skip to content

Commit

Permalink
Replace term 'dataframe' by 'data frame' anywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
florisvdh committed Nov 27, 2023
1 parent 33f7be7 commit 1b620a9
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 98 deletions.
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ Recommended resources to get started are:
- have a quick look at the [tidyverse style guide](https://style.tidyverse.org/).
There you see how to style object, variable and function names, as well as the documentation.
At least keep in mind: **use lower case and 'snake_case'** for object, variable and function names.
- if your function returns a dataframe, use `dplyr::as_tibble()` to return it as a tibble instead.
A tibble is a dataframe that makes working in the tidyverse a little [easier](https://r4ds.had.co.nz/tibbles.html).
- if your function returns a data frame, use `dplyr::as_tibble()` to return it as a tibble instead.
A tibble is a data frame that makes working in the tidyverse a little [easier](https://r4ds.had.co.nz/tibbles.html).
- functions that read or process data should return data as much as possible internationalized:
- availability of English names for types, environmental pressures, ...
Other languages can be accommodated as well;
- English names for table headings (dataframe variables).
- English names for table headings (data frame variables).


### How to contribute code?
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ For the moment not taking further measures to protect against it, as the package

# watina 0.4.1 (2021-06-11)

- Fixed non-working `get_xg3()` and `get_chem()` for dataframe input, by avoiding the currently defunct `dbplyr::db_drop_table()` (#89, [08bc66d](https://github.com/inbo/watina/commit/08bc66d)).
- Fixed non-working `get_xg3()` and `get_chem()` for data frame input, by avoiding the currently defunct `dbplyr::db_drop_table()` (#89, [08bc66d](https://github.com/inbo/watina/commit/08bc66d)).
- Various maintenance (#81, #86, #87, #88, [c382499](https://github.com/inbo/watina/commit/c382499)).

# watina 0.4.0 (2021-01-18)
Expand Down
10 changes: 5 additions & 5 deletions R/cluster.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Detect (spatial) groundwater well clusters
#'
#' \code{cluster_locs()} accepts as input a
#' dataframe with X/Y coordinates, or an \code{sf} object
#' data frame with X/Y coordinates, or an \code{sf} object
#' of geometry type \code{POINT}.
#' The function adds an integer variable that defines cluster membership.
#' The intention is to detect spatial groundwater well clusters; hence it uses a
Expand All @@ -18,9 +18,9 @@
#'
#' The function's code was partly inspired by unpublished code from Ivy Jansen.
#'
#' @param input A dataframe with X/Y coordinates, or an \code{sf} object of
#' @param input A data frame with X/Y coordinates, or an \code{sf} object of
#' geometry type \code{POINT}.
#' A typical input dataframe is the collected output of \code{\link{get_locs}}.
#' A typical input data frame is the collected output of \code{\link{get_locs}}.
#' @param max_dist The maximum geospatial distance between two points to make
#' them belong to the same cluster.
#' The default value is sensible for many usecases,
Expand All @@ -32,11 +32,11 @@
#' \code{input}.
#' @param xvar String.
#' The X coordinate variable name; only considered when \code{input} is a
#' dataframe.
#' data frame.
#' Defaults to \code{"x"}.
#' @param yvar String.
#' The Y coordinate variable name; only considered when \code{input} is a
#' dataframe.
#' data frame.
#' Defaults to \code{"y"}.
#'
#' @return
Expand Down
2 changes: 1 addition & 1 deletion R/eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ eval_chem <- function(data,
type <- match.arg(type)

assert_that(inherits(data, what = c("tbl_lazy", "data.frame")),
msg = "data must be a lazy object or a dataframe.")
msg = "data must be a lazy object or a data frame.")
assert_that(all(c("loc_code",
"date",
"lab_sample_id",
Expand Down
2 changes: 1 addition & 1 deletion R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ get_locs <- function(con,
#' If you like to print the lazy object in a sorted manner, you must add
#' `%>% arrange(...)` yourself.
#'
#' @param locs A \code{tbl_lazy} object or a dataframe, with at least a column
#' @param locs A \code{tbl_lazy} object or a data frame, with at least a column
#' \code{loc_code} that defines the locations for which values are to be
#' returned.
#' Typically, this will be the object returned by \code{\link{get_locs}}.
Expand Down
84 changes: 42 additions & 42 deletions R/selectlocs.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' Hence, the result will depend both on the XG3 \emph{types} (HG3, LG3 and/or
#' VG3) for which statistics have been computed (specified by \code{xg3_type}),
#' and on the conditions, specified by \code{conditions}.
#' See the devoted section on the \code{conditions} dataframe.
#' See the devoted section on the \code{conditions} data frame.
#'
#' Only locations are returned:
#' \itemize{
Expand All @@ -34,7 +34,7 @@
#' conditions are met;
#' }
#' }
#' As the conditions imposed by the \code{conditions} dataframe are always
#' As the conditions imposed by the \code{conditions} data frame are always
#' evaluated as a
#' required combination of conditions ('and'), the user must make different
#' calls to \code{selectlocs_xg3()}
Expand All @@ -50,7 +50,7 @@
#'
#' \code{selectlocs_xg3()} joins the long-formatted results of
#' \code{\link{eval_xg3_avail}} and \code{\link{eval_xg3_series}}
#' with the \code{conditions} dataframe in order to evaluate the conditions.
#' with the \code{conditions} data frame in order to evaluate the conditions.
#' Often, this join in itself already leads to dropping specific
#' combinations of \code{loc_code} and \code{xg3_variable}.
#' At least the locations that are completely dropped in this step are reported
Expand All @@ -69,13 +69,13 @@
#' \code{xg3_type}, \code{max_gap} and \code{min_dur} are not needed
#' (they will be ignored).
#'
#' @section Specification of the conditions dataframe:
#' @section Specification of the conditions data frame:
#' Conditions can be specified for each of the summary statistics returned
#' by \code{\link{eval_xg3_avail}} and \code{\link{eval_xg3_series}}.
#' Consequently, XG3 availability conditions and
#' XG3 series conditions can be distinguished.
#'
#' The \code{conditions} parameter takes a dataframe that must have the
#' The \code{conditions} parameter takes a data frame that must have the
#' following columns:
#' \describe{
#' \item{\code{xg3_variable}}{One of: \code{"combined","lg3_lcl","lg3_ost",
Expand All @@ -95,8 +95,8 @@
#' }
#' }
#'
#' Each condition is one row of the dataframe.
#' The dataframe should have at least one, and may have many.
#' Each condition is one row of the data frame.
#' The data frame should have at least one, and may have many.
#' Each combination of \code{xg3_variable} and \code{statistic} must be
#' unique.
#' Conditions on XG3 variables, absent from \code{data} or not implied by
Expand Down Expand Up @@ -130,7 +130,7 @@
#' Specifies the 'X' in 'XG3': either \code{"L"}, \code{"H"} and/or \code{"V"}.
#' Together with the available variables in \code{data},
#' \code{xg3_type} determines the meaning of the variable \code{"combined"}.
#' @param conditions A dataframe.
#' @param conditions A data frame.
#' See the devoted section below.
#' @param verbose Logical.
#' If \code{TRUE}, give feedback on dropped locations because of
Expand Down Expand Up @@ -368,13 +368,13 @@ selectlocs_xg3 <- function(data,
"criterion",
"direction") %in%
colnames(conditions)),
msg = "The conditions dataframe does not have the required column names.")
msg = "The conditions data frame does not have the required column names.")

assert_that(nrow(conditions) > 0,
msg = "You must at least provide one condition in the conditions dataframe.")
msg = "You must at least provide one condition in the conditions data frame.")

assert_that(all(!is.na(conditions)),
msg = "You must not leave empty cells in the conditions dataframe.")
msg = "You must not leave empty cells in the conditions data frame.")

assert_that(all(conditions$xg3_variable %in% c("combined",
"lg3_lcl",
Expand All @@ -383,22 +383,22 @@ selectlocs_xg3 <- function(data,
"vg3_ost",
"hg3_lcl",
"hg3_ost")),
msg = "You specified unknown XG3 variables in the conditions dataframe. Please fix.")
msg = "You specified unknown XG3 variables in the conditions data frame. Please fix.")

assert_that(is.numeric(conditions$criterion),
msg = "The 'criterion' variable of the conditions dataframe must be numeric. Please fix.")
msg = "The 'criterion' variable of the conditions data frame must be numeric. Please fix.")

assert_that(all(conditions$direction %in% c("min",
"max",
"equal")),
msg = "Directions in the conditions dataframe must be 'min', 'max' or 'equal'. Please fix.")
msg = "Directions in the conditions data frame must be 'min', 'max' or 'equal'. Please fix.")

assert_that({
conditions %>%
count(.data$xg3_variable, .data$statistic) %>%
filter(.data$n > 1) %>%
nrow(.) == 0},
msg = "You cannot repeat the same combination of xg3_variable and statistic in the conditions dataframe.")
msg = "You cannot repeat the same combination of xg3_variable and statistic in the conditions data frame.")

unknown_statnames <-
conditions %>%
Expand All @@ -422,7 +422,7 @@ selectlocs_xg3 <- function(data,

assert_that(length(unknown_statnames) == 0,
msg = paste0(
"The following 'statistic' names in the conditions dataframe are unknown: ",
"The following 'statistic' names in the conditions data frame are unknown: ",
paste(unknown_statnames, collapse = ", "),
". Please fix."
)
Expand All @@ -436,7 +436,7 @@ selectlocs_xg3 <- function(data,
if (any(str_detect(unique(conditions$statistic), "ser_"))) TRUE else FALSE

assert_that(cond_has_avail | cond_has_ser,
msg = "The conditions dataframe has no known 'statistic' names.")
msg = "The conditions data frame has no known 'statistic' names.")

## 1. Collecting statistics

Expand Down Expand Up @@ -730,7 +730,7 @@ selectlocs_xg3 <- function(data,
#' Hence, the result will depend both on the \emph{chemical variables} for
#' which statistics have been computed (specified by \code{chem_var}),
#' and on the conditions, specified by \code{conditions}.
#' See the devoted section on the \code{conditions} dataframe.
#' See the devoted section on the \code{conditions} data frame.
#'
#' Only locations are returned:
#' \itemize{
Expand All @@ -744,7 +744,7 @@ selectlocs_xg3 <- function(data,
#' conditions are met;
#' }
#' }
#' As the conditions imposed by the \code{conditions} dataframe are always
#' As the conditions imposed by the \code{conditions} data frame are always
#' evaluated as a
#' required combination of conditions ('and'), the user must make different
#' calls to \code{selectlocs_chem()}
Expand All @@ -753,11 +753,11 @@ selectlocs_xg3 <- function(data,
#' If \code{data_type = "data"}, \code{selectlocs_chem()} calls
#' \code{\link{eval_chem}}.
#' Its \code{type} and \code{uniformity_test} arguments are derived from the
#' user-specified \code{conditions} dataframe.
#' user-specified \code{conditions} data frame.
#'
#' \code{selectlocs_chem()} joins the long-formatted results of
#' \code{\link{eval_chem}}
#' with the \code{conditions} dataframe in order to evaluate the conditions.
#' with the \code{conditions} data frame in order to evaluate the conditions.
#' Often, this join in itself already leads to dropping specific
#' combinations of \code{loc_code} and \code{chem_variable}.
#' At least the locations that are completely dropped in this step are reported
Expand All @@ -772,11 +772,11 @@ selectlocs_xg3 <- function(data,
#' with \code{data_type = "summary"}.
#' In that case the argument \code{chem_var} is ignored.
#'
#' @section Specification of the conditions dataframe:
#' @section Specification of the conditions data frame:
#' Conditions can be specified for each of the summary statistics returned
#' by \code{\link{eval_chem}}.
#'
#' The \code{conditions} parameter takes a dataframe that must have the
#' The \code{conditions} parameter takes a data frame that must have the
#' following columns:
#' \describe{
#' \item{\code{chem_variable}}{Can be any chemical variable code,
Expand All @@ -802,8 +802,8 @@ selectlocs_xg3 <- function(data,
#' }
#' }
#'
#' Each condition is one row of the dataframe.
#' The dataframe should have at least one, and may have many.
#' Each condition is one row of the data frame.
#' The data frame should have at least one, and may have many.
#' Each combination of \code{chem_variable} and \code{statistic} must be
#' unique.
#' Conditions on chemical variables, absent from \code{data} or not implied by
Expand All @@ -825,7 +825,7 @@ selectlocs_xg3 <- function(data,
#' codes from the column \code{chem_variable} in \code{data}.
#' Together with the available variables in \code{data},
#' \code{chem_var} determines the meaning of the variable \code{"combined"}.
#' @param conditions A dataframe.
#' @param conditions A data frame.
#' See the devoted section below.
#' @param verbose Logical.
#' If \code{TRUE}, give feedback on dropped locations because of
Expand Down Expand Up @@ -975,10 +975,10 @@ selectlocs_chem <- function(data,
"criterion",
"direction") %in%
colnames(conditions)),
msg = "The conditions dataframe does not have the required column names.")
msg = "The conditions data frame does not have the required column names.")

assert_that(nrow(conditions) > 0,
msg = "You must at least provide one condition in the conditions dataframe.")
msg = "You must at least provide one condition in the conditions data frame.")

selectlocs(data = data,
data_type = data_type,
Expand Down Expand Up @@ -1038,19 +1038,19 @@ selectlocs_chem <- function(data,
#'
#' Generic (helper) function to select locations that comply with
#' user-specified conditions,
#' from either a dataset (dataframe or lazy object) with the variable's values or
#' from a dataframe with summary statistics.
#' from either a dataset (data frame or lazy object) with the variable's values or
#' from a data frame with summary statistics.
#'
#' The result of the evaluation function (\code{eval_fun}) must produce a
#' dataframe, formatted as declared by the second bullet under the
#' data frame, formatted as declared by the second bullet under the
#' \code{data} argument.
#'
#' @param data Either:
#' \itemize{
#' \item{a dataset (dataframe or lazy object) with the variable's values}:
#' \item{a dataset (data frame or lazy object) with the variable's values}:
#' with at least a column \code{loc_code}, a column with the variable name,
#' and a column \code{value};
#' \item{a dataframe with summary statistics}:
#' \item{a data frame with summary statistics}:
#' with a first column \code{loc_code} and a second column with the evaluated
#' variable names or codes.
#' The column name of the second column can vary.
Expand All @@ -1064,7 +1064,7 @@ selectlocs_chem <- function(data,
#' dataset.
#' @param eval_args The arguments of the evaluation function, as a named list,
#' if \code{data} is a dataset.
#' @param conditions A dataframe.
#' @param conditions A data frame.
#' It must have the
#' following columns:
#' \describe{
Expand All @@ -1084,8 +1084,8 @@ selectlocs_chem <- function(data,
#' }
#' }
#'
#' Each condition is one row of the dataframe.
#' The dataframe should have at least one, and may have many.
#' Each condition is one row of the data frame.
#' The data frame should have at least one, and may have many.
#' Each combination of \code{chem_variable} and \code{statistic} must be
#' unique.
#' Conditions on chemical variables, absent from \code{data} or not implied by
Expand Down Expand Up @@ -1175,28 +1175,28 @@ selectlocs <- function(data,
"criterion",
"direction") %in%
colnames(conditions)),
msg = "The conditions dataframe does not have the required column names.")
msg = "The conditions data frame does not have the required column names.")

assert_that(nrow(conditions) > 0,
msg = "You must at least provide one condition in the conditions dataframe.")
msg = "You must at least provide one condition in the conditions data frame.")

assert_that(all(!is.na(conditions)),
msg = "You must not leave empty cells in the conditions dataframe.")
msg = "You must not leave empty cells in the conditions data frame.")

assert_that(is.numeric(conditions$criterion),
msg = "The 'criterion' variable of the conditions dataframe must be numeric. Please fix.")
msg = "The 'criterion' variable of the conditions data frame must be numeric. Please fix.")

assert_that(all(conditions$direction %in% c("min",
"max",
"equal")),
msg = "Directions in the conditions dataframe must be 'min', 'max' or 'equal'. Please fix.")
msg = "Directions in the conditions data frame must be 'min', 'max' or 'equal'. Please fix.")

assert_that({
conditions %>%
count(.data$variable, .data$statistic) %>%
filter(.data$n > 1) %>%
nrow(.) == 0},
msg = "You cannot repeat the same combination of variable and statistic in the conditions dataframe.")
msg = "You cannot repeat the same combination of variable and statistic in the conditions data frame.")

## 1. Collecting statistics

Expand Down
10 changes: 5 additions & 5 deletions R/sf.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#' Convert a dataframe with X and Y coordinates to a geospatial points object
#' Convert a data frame with X and Y coordinates to a geospatial points object
#'
#' \code{as_points} is a convenience function which accepts as input a dataframe
#' \code{as_points} is a convenience function which accepts as input a data frame
#' with X/Y coordinates (in meters), assumed to come from the coordinate
#' reference system (CRS)
#' 'Belge 1972 / Belgian Lambert 72' (EPSG \href{https://epsg.io/31370}{31370}).
#' It converts the dataframe into an \code{sf} points object in the same CRS.
#' It converts the data frame into an \code{sf} points object in the same CRS.
#'
#' As locations in Watina are typically defined by their X/Y coordinates,
#' this function eases the conversion to spatial data.
#' To later remove all spatial information from the result, you can use
#' \code{\link[sf:st_geometry]{sf::st_drop_geometry()}}.
#'
#' @param df A dataframe with X and Y coordinates in meters, assumed to be in
#' @param df A data frame with X and Y coordinates in meters, assumed to be in
#' the Belgian Lambert 72 CRS (EPSG-code 31370).
#' @param xvar String. The X coordinate variable name. Defaults to \code{"x"}.
#' @param yvar String. The Y coordinate variable name. Defaults to \code{"y"}.
#' @param remove Logical. Should the X and Y coordinates be removed from the
#' dataframe after conversion to a spatial object?
#' data frame after conversion to a spatial object?
#' @param warn_dupl Logical.
#' Defaults to \code{TRUE}.
#' Should the user be warned when duplicated coordinates are present in the
Expand Down
Loading

0 comments on commit 1b620a9

Please sign in to comment.