Skip to content

Commit

Permalink
Merge pull request #78 from inbo/dev_nextrelease
Browse files Browse the repository at this point in the history
Releasing watina 0.4.0
  • Loading branch information
florisvdh authored Jan 18, 2021
2 parents e115f31 + 2ed7cd9 commit 527a473
Show file tree
Hide file tree
Showing 33 changed files with 550 additions and 400 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.github/
^docs$
^_pkgdown\.yml$
^pkgdown$
^\.travis\.yml$
^appveyor\.yml$
^\.zenodo\.json$
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "GPL-3.0",
"upload_type": "software",
"access_right": "open",
"version": "0.3.0",
"version": "0.4.0",
"creators": [
{
"name": "Vanderhaeghe, Floris",
Expand Down
11 changes: 6 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: watina
Title: Querying And Processing Data From The INBO Watina Database
Version: 0.3.0
Version: 0.4.0
Description: The R-package watina contains functions to query
and process data from the Watina database at the Research Institute for
Nature and Forest (INBO). This database primarily provides
Expand Down Expand Up @@ -34,11 +34,12 @@ Imports:
tidyr
Suggests:
knitr,
rmarkdown
purrr,
rmarkdown,
tidyselect
Remotes:
inbo/inbodb,
florisvdh/dbplyr@dbplyr_with_pivot_wider
inbo/inbodb
LazyData: true
Encoding: UTF-8
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
VignetteBuilder: knitr
15 changes: 11 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

export(as_points)
export(cluster_locs)
export(collect)
export(connect_watina)
export(convertdf_enc)
export(dbDisconnect)
export(eval_chem)
export(eval_xg3_avail)
export(eval_xg3_series)
Expand All @@ -23,12 +22,12 @@ importFrom(assertthat,is.flag)
importFrom(assertthat,is.number)
importFrom(assertthat,is.string)
importFrom(assertthat,noNA)
importFrom(dbplyr,db_pivot_wider)
importFrom(dplyr,"%>%")
importFrom(dplyr,anti_join)
importFrom(dplyr,arrange)
importFrom(dplyr,as_tibble)
importFrom(dplyr,bind_cols)
importFrom(dplyr,collect)
importFrom(dplyr,contains)
importFrom(dplyr,copy_to)
importFrom(dplyr,count)
Expand All @@ -43,7 +42,6 @@ importFrom(dplyr,lead)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,mutate_at)
importFrom(dplyr,mutate_if)
importFrom(dplyr,n)
importFrom(dplyr,pull)
importFrom(dplyr,rename)
Expand All @@ -60,6 +58,7 @@ importFrom(dplyr,tribble)
importFrom(dplyr,ungroup)
importFrom(dplyr,vars)
importFrom(inbodb,connect_inbo_dbase)
importFrom(inbodb,dbDisconnect)
importFrom(lubridate,as_date)
importFrom(lubridate,day)
importFrom(lubridate,dmy)
Expand All @@ -68,6 +67,14 @@ importFrom(lubridate,now)
importFrom(lubridate,today)
importFrom(lubridate,year)
importFrom(rlang,.data)
importFrom(rlang,enquo)
importFrom(rlang,enquos)
importFrom(rlang,expr)
importFrom(rlang,flatten)
importFrom(rlang,quo_get_expr)
importFrom(rlang,set_names)
importFrom(rlang,sym)
importFrom(rlang,syms)
importFrom(sf,st_as_sf)
importFrom(sf,st_buffer)
importFrom(sf,st_coordinates)
Expand Down
32 changes: 24 additions & 8 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# watina 0.3.0
# watina 0.4.0 (2021-01-18)

- This release has been made compatible with `dbplyr` 2.0.0 (on CRAN); the `dbplyr` fork is not needed anymore ([e66e58f](https://github.com/inbo/watina/commit/e66e58f), #74).
- Follow the installation procedure on the homepage (readme) to upgrade.
- Lazy results of `get_locs()`, `get_xg3()` and `get_chem()` are not sorted anymore.
Sorting is done in tibbles only, i.e. if `collect = TRUE`.
For more information, consult the _Note_ added in the documentation of these functions.
- Fix broken `selectlocs_xg3()` and `selectlocs_chem()` (#73).
- Fix `get_locs()` error when no locations remain after spatial masking ([c96421e](https://github.com/inbo/watina/commit/c96421e)).
- Fix `get_locs()` error when `obswell_aggr = "mean"` (#80).
- Adopt further [`inbodb`](https://inbo.github.io/inbodb) functionality (#75):
- re-export its `dbDisconnect()`;
- transfer handling of character encoding to `inbodb`.
- Improve documentation and `pkgdown` website (#76, #77, [3986b4e](https://github.com/inbo/watina/commit/3986b4e)).


# watina 0.3.0 (2020-05-20)

#### New features

Expand All @@ -14,34 +30,34 @@

Further, a number of smaller fixes and enhancements were made.

# watina 0.2.6
# watina 0.2.6 (2020-02-28)

- Redo fix `get_locs()`: calculation of `soilsurf_ost` (#43)

# watina 0.2.5
# watina 0.2.5 (2020-02-27)

- Bugfix in `get_locs()`: calculation of `soilsurf_ost` (#42)

# watina 0.2.4
# watina 0.2.4 (2020-01-29)

- Bugfix in `convertdf_enc()` (#34)
- Some small documentation improvements

# watina 0.2.3
# watina 0.2.3 (2020-01-09)

- Documentation is now generated by the newer `roxygen2` version `7.0.2`, resulting in a better layout of function arguments in the 'usage' section.

# watina 0.2.2
# watina 0.2.2 (2019-11-04)

- On Windows, the functions now convert 'weird' characters from the database to proper UTF-8.
- Bugfix (#29) in `get_locs()` regarding the default implementation of the `loc_validity` argument.

# watina 0.2.1
# watina 0.2.1 (2019-10-14)

- Fixed bug in some hyperlinks in function documentation,
affecting the installation process on Windows (warnings were thrown).

# watina 0.2.0
# watina 0.2.0 (2019-10-02)

#### New features

Expand Down
2 changes: 1 addition & 1 deletion R/cluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
#' table
#'
#' # Disconnect:
#' DBI::dbDisconnect(watina)
#' dbDisconnect(watina)
#' }
#'
#' @export
Expand Down
20 changes: 17 additions & 3 deletions R/connect_watina.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' The function can only be used from within the INBO network.
#'
#' Don't forget to disconnect at the end of your R-script using
#' \code{\link[DBI:dbDisconnect]{DBI::dbDisconnect()}}!
#' \code{\link{dbDisconnect}}!
#'
#' @return
#' A \code{DBIConnection} object.
Expand All @@ -14,12 +14,26 @@
#' watina <- connect_watina()
#' # Do your stuff.
#' # Disconnect:
#' DBI::dbDisconnect(watina)
#' dbDisconnect(watina)
#' }
#'
#' @export
#' @importFrom inbodb connect_inbo_dbase
connect_watina <- function() {
connect_inbo_dbase("W0002_00_Watina")
connect_inbo_dbase("W0002_00_Watina",
autoconvert_utf8 = TRUE)
}



#' Disconnect a database connection
#'
#' This is a re-export of
#' \code{\link[inbodb:dbDisconnect-OdbcConnection-method]{inbodb::dbDisconnect()}}
#' (\href{https://inbo.github.io/inbodb/reference/dbDisconnect-OdbcConnection-method.html}{url}).
#'
#' @name dbDisconnect
#' @keywords documentation
#' @importFrom inbodb dbDisconnect
#' @export dbDisconnect
NULL
82 changes: 82 additions & 0 deletions R/db_pivot_wider.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# NOTE: all credits for this db_pivot_wider function go to Edgar Ruiz.
# He made a PR where this function was proposed to incorporate in dbplyr:
# https://github.com/tidyverse/dbplyr/pull/344
# The code below is a copy and the terms of its original code source apply.
# Minor modifications were made in the approach to import rlang functions and to
# avoid global variables.

#' @importFrom rlang
#' .data
#' sym
#' syms
#' set_names
#' flatten
#' enquo
#' enquos
#' quo_get_expr
#' expr
#' @keywords internal
db_pivot_wider <- function(data,
id_cols = NULL,
names_from = .data$name,
names_prefix = "",
names_sep = NULL,
names_repair = NULL,
values_from = .data$value,
values_fill = NULL,
values_fn = NULL,
spec = NULL) {
if (!requireNamespace("tidyselect", quietly = TRUE)) {
stop("Package \"tidyselect\" is needed when using this function. ",
"Please install it.",
call. = FALSE)
}
if (!requireNamespace("purrr", quietly = TRUE)) {
stop("Package \"purrr\" is needed when using this function. ",
"Please install it.",
call. = FALSE)
}
check_null_pivot_args(
id_cols = !!id_cols, names_sep = !!names_sep,
names_repair = !!names_repair, values_fill = !!values_fill,
values_fn = !!values_fn, spec = !!spec
)
cn <- colnames(data)
names_from <- tidyselect::vars_select(cn, !!enquo(names_from))
values_from <- tidyselect::vars_select(cn, !!enquo(values_from))
pl <- c(values_from, names_from)
kp <- cn[!(cn %in% pl)]
headers <- pull(summarise(group_by(data, !!sym(names_from))))
mt <- purrr::map(
headers,
~ {
header <- .x
purrr::map(
values_from,
~ expr(max(ifelse(!!sym(names_from) == !!header, !!sym(.x), NA), na.rm = TRUE))
)
}
)
fmt <- flatten(mt)
if (length(values_from) > 1) {
vp <- paste0(values_from, "_")
} else {
vp <- ""
}
hn <- purrr::map(headers, ~ paste0(vp, names_prefix, .x))
rhn <- purrr::reduce(hn, c)
nmt <- set_names(fmt, rhn)
grps <- group_by(data, !!!syms(kp))
summarise(grps, !!!nmt)
}

check_null_pivot_args <- function(..., msg = "The `{arg}` argument is not supported for remote back-ends") {
vars <- enquos(...)
purrr::imap(
vars,
~ assert_that(
is.null(quo_get_expr(.x)),
msg = sub("\\{arg\\}", .y, msg)
)
)
}
104 changes: 0 additions & 104 deletions R/encode_utf8.R

This file was deleted.

Loading

0 comments on commit 527a473

Please sign in to comment.