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
@@ -1,7 +1,7 @@
Package: fundiversity
Title: Easy Computation of Functional Diversity Indices
Version: 1.1.1
Authors@R:
Authors@R:
c(
person("Matthias", "Grenié",
email = "matthias.grenie@gmail.com",
Expand All @@ -24,8 +24,8 @@ Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Depends:
R (>= 2.10)
Depends:
R (>= 3.2.0)
Imports:
future.apply,
geometry,
Expand Down
9 changes: 2 additions & 7 deletions R/fd_feve.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
#' @export
fd_feve <- function(traits = NULL, sp_com, dist_matrix = NULL) {

if ((!is.null(traits) && !is.null(dist_matrix)) ||
(is.null(traits) && is.null(dist_matrix))) {
if (!xor(is.null(traits), is.null(dist_matrix))) {
stop(
"Please provide either a trait dataset or a dissimilarity matrix",
call. = FALSE
Expand Down Expand Up @@ -71,11 +70,7 @@ fd_feve <- function(traits = NULL, sp_com, dist_matrix = NULL) {
)
}

if (is.null(rownames(sp_com))) {

rownames(sp_com) <- paste0("s", seq_len(nrow(sp_com)))

}
rownames(sp_com) <- rownames(sp_com) %||% paste0("s", seq_len(nrow(sp_com)))

# Standardize abundance per site
site_abundances <- rowSums(sp_com, na.rm = TRUE)
Expand Down
7 changes: 2 additions & 5 deletions R/fd_fric_intersect.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@ fd_fric_intersect <- function(traits, sp_com, stand = FALSE) {

}

if (is.null(rownames(sp_com))) {
rownames(sp_com) <- rownames(sp_com) %||% paste0("s", seq_len(nrow(sp_com)))

rownames(sp_com) <- paste0("s", seq_len(nrow(sp_com)))

}

max_range <- 1

Expand Down Expand Up @@ -145,7 +142,7 @@ fd_fric_intersect <- function(traits, sp_com, stand = FALSE) {
}
}, future.globals = FALSE)

if (any(is.na(fric_intersect))) {
if (anyNA(fric_intersect)) {
warning(
"Some sites had less species than traits so returned FRic_intersect ",
"is 'NA'",
Expand Down
9 changes: 2 additions & 7 deletions R/fd_raoq.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
#' @export
fd_raoq <- function(traits = NULL, sp_com, dist_matrix = NULL) {

if ((!is.null(traits) && !is.null(dist_matrix)) ||
(is.null(traits) && is.null(dist_matrix))) {
if (!xor(is.null(traits), is.null(dist_matrix))) {
stop(
"Please provide either a trait dataset or a dissimilarity matrix",
call. = FALSE
Expand Down Expand Up @@ -79,11 +78,7 @@ fd_raoq <- function(traits = NULL, sp_com, dist_matrix = NULL) {

}

if (is.null(rownames(sp_com))) {

rownames(sp_com) <- paste0("s", seq_len(nrow(sp_com)))

}
rownames(sp_com) <- rownames(sp_com) %||% paste0("s", seq_len(nrow(sp_com)))

# Standardize abundance per site
site_abundances <- rowSums(sp_com, na.rm = TRUE)
Expand Down
9 changes: 9 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This can be deleted in favour of base R version if we ever start depending
# on R (>= 4.4.0)
`%||%` <- function(x, y) {
if (is.null(x)) {
y
} else {
x
}
}
3 changes: 1 addition & 2 deletions vignettes/_fundiversity_2-performance.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ all_bench_sites <- list(fric = bench_sites_fric,
raoq = bench_sites_raoq,
feve = bench_sites_feve) %>%
bind_rows(.id = "fd_index") %>%
mutate(n_sites = gsub("sites", "", expr) %>%
as.numeric())
mutate(n_sites = as.numeric(gsub("sites", "", expr, fixed = TRUE)))

all_bench_sites %>%
ggplot(aes(n_sites, time * 1e-9, color = fd_index)) +
Expand Down
Loading