Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with R <4.1/4.2 #317

Merged
merged 6 commits into from
Aug 3, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge branch 'master' into r4compat
  • Loading branch information
brownag authored Jun 24, 2024
commit a68c43d99fddb3031cd245e56178f5c32b99dec5
21 changes: 18 additions & 3 deletions R/texture.R
Original file line number Diff line number Diff line change
Expand Up @@ -1081,16 +1081,31 @@ fragvol_to_texmod <- function(
#'

lookup_taxpartsize <- function() {

fe <- rev(c("fragmental", "pumiceous", "cindery", "sandy-skeletal", "loamy-skeletal", "gypseous-skeletal", "ashy-skeletal", "medial-skeletal", "ashy-pumiceous", "medial-pumiceous", "clay-skeletal", "sandy", "ashy", "coarse-loamy", "coarse-silty", "coarse-gypseous", "medial", "loamy", "fine-gypseous", "fine-loamy", "fine-silty", "hydrous", "fine", "clayey", "very-fine", "diatomaceous"))
fe <- c("diatomaceous", "very-fine", "clayey", "fine", "hydrous", "fine-silty",
"fine-gypseous", "fine-loamy", "medial", "loamy", "coarse-loamy",
"coarse-silty", "coarse-gypseous", "ashy", "sandy", "hydrous-pumiceous",
"medial-pumiceous", "ashy-pumiceous", "clayey-skeletal", "hydrous-skeletal",
"medial-skeletal", "loamy-skeletal", "gypseous-skeletal", "ashy-skeletal",
"sandy-skeletal", "pumiceous", "cindery", "fragmental")

rank <- c(84, 74, 60.02, 46.04, 44.04, 26, 25.8, 25.6, 24, 17.24, 8.88,
8.5, 7.5, 6.5, 4.67, -55.96, -76, -93.5, -43.33, -55.96, -76,
-83.23, -83.35, -93.5, -95.33, -95.83, -96.33, -98.94)
names(rank) <- fe

# cf <- c("fragmental", "sandy-skeletal", "loamy-skeletal", "clay-skeletal")

test <- strsplit(.pscs_sc, " over | or ")
names(test) <- .pscs_sc

idx <- lapply(test, function(x) {
idx <- unlist(sapply(x, function(y) which(fe == y)))
idx <- unlist(sapply(x, function(y) rank[which(fe == y)]))

# select the 3rd value when "or" results in 3 values
if (length(idx) > 2) idx <- c(idx[1], idx[3])

dif <- diff(idx)
idx <- idx[1] + sqrt(abs(dif)) * sign(dif)
# l <- dplyr::lag(idx)
# l <- idx[c(NA, 1:(length(idx) - 1))]
# idx <- ifelse(idx < l & !is.na(l), idx * -1, idx * 1)
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.