From f18e7b94483deebc77bb6ebed8eeb03a9a24aab2 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Mon, 24 Jun 2024 14:16:57 -0700 Subject: [PATCH 1/5] Fix compatibility with R <4.1/4.2 --- R/allocate.R | 50 +++++++++++-------------- R/segment.R | 90 ++++++++++++++++++--------------------------- R/texture.R | 7 ++-- man/hz_intersect.Rd | 20 +++++----- man/hz_lag.Rd | 16 ++++---- 5 files changed, 75 insertions(+), 108 deletions(-) diff --git a/R/allocate.R b/R/allocate.R index 84f4ee5a..fc1ad128 100644 --- a/R/allocate.R +++ b/R/allocate.R @@ -747,20 +747,18 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", # dissolve on pscs ---- # calculate non-trimmed horizon thickness - x_dis <- x |> - hz_dissolve(by = "taxpartsize", idcol = "idcol", depthcols = c("top", "bot")) |> - transform(thk_o = bot - top) + x_dis <- transform(hz_dissolve(x, by = "taxpartsize", idcol = "idcol", depthcols = c("top", "bot")), + thk_o = bot - top) # trim depths ---- # calculate trimmed horizon thickness - xy_dis <- x_dis |> - hz_intersect(y, idcol = "idcol", depthcols = c("top", "bot")) |> - transform(thk_t = bot - top) + xy_dis <- transform(hz_intersect(x_dis, y, idcol = "idcol", depthcols = c("top", "bot")), + thk_t = bot - top) # rejoin dissolved pscs to the original horizon table ---- - xy <- hz_intersect(x, xy_dis, idcol = "idcol", depthcols = c("top", "bot")) |> suppressWarnings() + xy <- suppressWarnings(hz_intersect(x, xy_dis, idcol = "idcol", depthcols = c("top", "bot"))) x_dis <- NULL xy_dis <- NULL @@ -790,8 +788,7 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", # find adjacent horizons ---- - xy_lag <- xy_agg |> - hz_lag(idcol = "idcol", depthcols = c("top", "bot")) + xy_lag <- hz_lag(xy_agg, idcol = "idcol", depthcols = c("top", "bot")) # address special cases of strongly contrasting classes ---- @@ -801,8 +798,7 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", # still needs special cases for very fine sand - xy_agg <- cbind(xy_agg, xy_lag) |> - within({ + xy_agg <- within(cbind(xy_agg, xy_lag), { clay_dif = clay_wt_bot.1 - clay_wt sc = paste0(taxpartsize, " over ", taxpartsize_bot.1) sc = gsub(" over NA$", "", sc) @@ -859,36 +855,32 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", n_sc <- NULL n_peiid <- NULL - test <- data.table::as.data.table(xy_agg)[, list( + test <- as.data.frame(data.table::as.data.table(xy_agg)[, list( n_sc = sum(idx_sc, na.rm = TRUE), # sum(grepl(" over ", sc), na.rm = TRUE), n_peiid = length(idx_sc) ), by = "idcol" - ] |> - as.data.frame() + ]) # pick the sc pscs with the largest contrast or pscs with the greatest thickness - xy_res <- xy_agg |> - merge(test, by = "idcol", all.x = TRUE, sort = FALSE) |> - transform( + xy_res <- transform(merge(xy_agg, test, by = "idcol", all.x = TRUE, sort = FALSE), idx_sc = sc %in% .pscs_sc, # idx_sc = grepl(" over ", sc), idx_c_ov_l = sc %in% c("clayey over fine-loamy") ) - xy_res <- data.table::as.data.table(xy_res)[, list( - pscs1 = sc[n_sc == 0 & n_peiid == 1], - pscs2 = sc[n_sc == 1 & n_peiid > 1 & idx_sc], - pscs3 = sc[which.max(thk_t[n_sc == 0 & n_peiid > 1])], - pscs4 = sc[n_sc == 1 & idx_sc], - pscs5 = sc[which.max(abs(clay_dif[n_sc > 1 & !is.na(sc)]))], - taxpartsizemod = ifelse(max(n_sc) > 1, "aniso", "not used") - ), - by = "idcol" - ] |> - as.data.frame() |> - within({ + xy_res <- + within(as.data.frame( + data.table::as.data.table(xy_res)[, list( + pscs1 = sc[n_sc == 0 & n_peiid == 1], + pscs2 = sc[n_sc == 1 & n_peiid > 1 & idx_sc], + pscs3 = sc[which.max(thk_t[n_sc == 0 & n_peiid > 1])], + pscs4 = sc[n_sc == 1 & idx_sc], + pscs5 = sc[which.max(abs(clay_dif[n_sc > 1 & !is.na(sc)]))], + taxpartsizemod = ifelse(max(n_sc) > 1, "aniso", "not used") + ), by = "idcol"]), + { # need to add fix for special case of sandy over loamy which requires fine sand percent taxpartsize = paste(pscs1, pscs3, pscs4, pscs5, sep = "") taxpartsize = gsub("NA", "", taxpartsize) diff --git a/R/segment.R b/R/segment.R index 1481cd00..7d7a86bc 100644 --- a/R/segment.R +++ b/R/segment.R @@ -383,12 +383,8 @@ hz_dissolve <- function(object, by, idcol = "id", depthcols = c("top", "bottom") # append dissolve_id - n <- c( - var_dep$top, - var_dep$bot - ) |> - nchar() |> - max(na.rm = TRUE) + n <- max(nchar(c(var_dep$top, var_dep$bot)), na.rm = TRUE) + var_dep$dissolve_id <- paste0( var_dep$idcol, "_", @@ -439,25 +435,20 @@ dissolve_hz <- function(object, by, id = "idcol", hztop = "top", hzbot = "bottom #' @examples #' #' h <- data.frame( -#' id = 1, -#' top = c(0, 25, 44, 46, 50), -#' bottom = c(25, 44, 46, 50, 100), -#' by = c("Yes", "Yes", "No", "No", "Yes"), -#' clay = c(10, 12, 27, 35, 16) +#' id = 1, +#' top = c(0, 25, 44, 46, 50), +#' bottom = c(25, 44, 46, 50, 100), +#' by = c("Yes", "Yes", "No", "No", "Yes"), +#' clay = c(10, 12, 27, 35, 16) #' ) #' -#' h |> hz_dissolve("by") +#' hz_dissolve(h, "by") #' -#' h |> hz_dissolve("by") |> hz_intersect(x = _, y = h) +#' hz_intersect(x = hz_dissolve(h, "by"), y = h) #' -#' h |> -#' hz_dissolve("by") |> -#' hz_intersect(x = h, y = _) |> -#' aggregate(clay ~ dissolve_id, data = _, mean) +#' hi <- hz_intersect(x = h, y = hz_dissolve(h, "by")) +#' aggregate(clay ~ dissolve_id, data = hi, mean) #' - - - hz_intersect <- function(x, y, idcol = "id", depthcols = c("top", "bottom")) { # test inputs ---- @@ -502,9 +493,7 @@ hz_intersect <- function(x, y, idcol = "id", depthcols = c("top", "bottom")) { if (nrow(yi) > 0) { - int <- c(xi$top, xi$bot, yi$top, yi$bot) |> - sort() |> - unique() + int <- unique(sort(c(xi$top, xi$bot, yi$top, yi$bot))) xi_seg <- hz_segment(xi, intervals = int, depthcols = names(x_conversion[2:3]), trim = TRUE) yi_seg <- hz_segment(yi, intervals = int, depthcols = names(x_conversion[2:3]), trim = TRUE) @@ -514,8 +503,8 @@ hz_intersect <- function(x, y, idcol = "id", depthcols = c("top", "bottom")) { }) ->.; - x_seg <- lapply(., function(x) x[["x_seg"]]) |> do.call("rbind", args = _) - y_seg <- lapply(., function(x) x[["y_seg"]]) |> do.call("rbind", args = _) + x_seg <- do.call("rbind", lapply(., function(x) x[["x_seg"]])) + y_seg <- do.call("rbind", lapply(., function(x) x[["y_seg"]])) xy_int <- merge(x_seg, y_seg, by = c("segment_id", "idcol", "top", "bot"), sort = FALSE) @@ -559,22 +548,17 @@ hz_intersect <- function(x, y, idcol = "id", depthcols = c("top", "bottom")) { #' clay = c(10, 12, 27, 35, 16) #' ) #' -#' h |> hz_lag() +#' hz_lag(h) #' -#' h |> hz_lag(-1) +#' hz_lag(h, -1) #' -#' h |> hz_lag(10:15, unit = "depth") +#' hz_lag(h, 10:15, unit = "depth") #' -#' h |> -#' hz_lag() |> -#' cbind(h, lag = _) |> -#' transform( -#' clay_dif = lag.clay_bot.1 - clay, -#' texcl_contrast = paste0(texcl, "-", lag.texcl_bot.1)) +#' transform(cbind(h, lag = hz_lag(h)), +#' clay_dif = lag.clay_bot.1 - clay, +#' texcl_contrast = paste0(texcl, "-", lag.texcl_bot.1) +#' ) #' - - - hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c("top", "bottom"), order = FALSE) { nm <- names(object) @@ -599,7 +583,7 @@ hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c( x <- x[x$bot < 1000, ] } - test <- aggregate(top ~ idcol, data = x, length)$top |> max() + test <- max(aggregate(top ~ idcol, data = x, length)$top) if (unit == "index") { if ((test - 1) < max(lag)) { stop("lag can not be greater than the maximum number of horizons") @@ -639,46 +623,42 @@ hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c( x_seg <- x_seg[1:(n + 1)] - x_seg <- lapply(lag, function(i) { - + x_seg <- do.call("cbind", args = lapply(lag, function(i) { x$bot_i <- x$bot + i - idx <- match( - paste(x$idcol, x$bot_i), - paste(x_seg$idcol, x_seg$bot) - ) - xi_seg <- x_seg[idx, ] + idx <- match(paste(x$idcol, x$bot_i), + paste(x_seg$idcol, x_seg$bot)) + xi_seg <- x_seg[idx,] xi_seg <- x[xi_seg$.ID, vars, drop = FALSE] xi_seg$.ID <- NULL - if (i >= 0) names(xi_seg) <- paste0(names(xi_seg), "_bot.", i) - if (i < 0) names(xi_seg) <- paste0(names(xi_seg), "_top.", abs(i)) + if (i >= 0) + names(xi_seg) <- paste0(names(xi_seg), "_bot.", i) + if (i < 0) + names(xi_seg) <- paste0(names(xi_seg), "_top.", abs(i)) return(xi_seg) - }) |> - do.call("cbind", args = _) + })) return(x_seg) } if (unit == "index") { - x_lag <- lapply(lag, function(i) { + x_lag <- do.call("cbind", lapply(lag, function(i) { .lag_ind(x, i) - }) |> - do.call("cbind", args = _) + })) x_lag <- x_lag[sort(names(x_lag))] } + if (unit == "depth") { x_lag <- .lag_dep(x, lag) x_lag <- x_lag[sort(names(x_lag))] } - # # reset inputs ---- x_lag <- .reset_inputs(x_lag, x_conversion) - return(x_lag) } @@ -747,4 +727,4 @@ hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c( return(x) } - \ No newline at end of file + diff --git a/R/texture.R b/R/texture.R index a3adb6d3..bf6ab546 100644 --- a/R/texture.R +++ b/R/texture.R @@ -1076,7 +1076,7 @@ fragvol_to_texmod <- function( PSCS_levels <- function() { - fe <- 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") |> rev() + 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")) # cf <- c("fragmental", "sandy-skeletal", "loamy-skeletal", "clay-skeletal") @@ -1084,7 +1084,7 @@ PSCS_levels <- function() { names(test) <- .pscs_sc idx <- lapply(test, function(x) { - idx <- sapply(x, function(y) which(fe == y)) |> unlist() + idx <- unlist(sapply(x, function(y) which(fe == y))) # l <- dplyr::lag(idx) l <- idx[c(NA, 1:(length(idx) - 1))] idx <- ifelse(idx < l & !is.na(l), idx * -1, idx * 1) @@ -1105,5 +1105,4 @@ PSCS_levels <- function() { } -.pscs_sc <- c("Ashy over clayey", "Ashy over clayey-skeletal", "Ashy over loamy", "Ashy over loamy-skeletal", "Ashy over medial", "Ashy over medial-skeletal", "Ashy over pumiceous or cindery", "Ashy over sandy or sandy-skeletal", "Ashy-skeletal over clayey", "Ashy-skeletal over fragmental or cindery", "Ashy-skeletal over loamy-skeletal", "Ashy-skeletal over sandy or sandy-skeletal", "Cindery over loamy", "Cindery over medial", "Cindery over medial-skeletal", "Clayey over coarse-gypseous", "Clayey over fine-gypseous", "Clayey over fragmental", "Clayey over gypseous-skeletal", "Clayey over loamy", "Clayey over loamy-skeletal", "Clayey over sandy or sandy-skeletal", "Clayey-skeletal over sandy or sandy-skeletal", "Coarse-loamy over clayey", "Coarse-loamy over fragmental", "Coarse-loamy over sandy or sandy-skeletal", "Coarse-silty over clayey", "Coarse-silty over sandy or sandy-skeletal", "Fine-loamy over clayey", "Fine-loamy over fragmental", "Fine-loamy over sandy or sandy-skeletal", "Fine-silty over clayey", "Fine-silty over fragmental", "Fine-silty over sandy or sandy-skeletal", "Hydrous over clayey", "Hydrous over clayey-skeletal", "Hydrous over fragmental", "Hydrous over loamy", "Hydrous over loamy-skeletal", "Hydrous over sandy or sandy-skeletal", "Loamy over ashy or ashy-pumiceous", "Loamy over coarse-gypseous", "Loamy over fine-gypseous", "Loamy over pumiceous or cindery", "Loamy over sandy or sandy-skeletal", "Loamy-skeletal over cindery", "Loamy-skeletal over clayey", "Loamy-skeletal over fragmental", "Loamy-skeletal over gypseous-skeletal", "Loamy-skeletal over sandy or sandy-skeletal", "Medial over ashy", "Medial over ashy-pumiceous or ashy-skeletal", "Medial over clayey", "Medial over clayey-skeletal", "Medial over fragmental", "Medial over hydrous", "Medial over loamy", "Medial over loamy-skeletal", "Medial over pumiceous or cindery", "Medial over sandy or sandy-skeletal", "Medial-skeletal over fragmental or cindery", "Medial-skeletal over loamy-skeletal", "Medial-skeletal over sandy or sandy-skeletal", "Pumiceous or ashy-pumiceous over loamy", "Pumiceous or ashy-pumiceous over loamy-skeletal", "Pumiceous or ashy-pumiceous over medial", "Pumiceous or ashy-pumiceous over medial-skeletal", "Pumiceous or ashy-pumiceous over sandy or sandy-skeletal", "Sandy over clayey", "Sandy over loamy", "Sandy-skeletal over loamy") |> - tolower() +.pscs_sc <- tolower(c("Ashy over clayey", "Ashy over clayey-skeletal", "Ashy over loamy", "Ashy over loamy-skeletal", "Ashy over medial", "Ashy over medial-skeletal", "Ashy over pumiceous or cindery", "Ashy over sandy or sandy-skeletal", "Ashy-skeletal over clayey", "Ashy-skeletal over fragmental or cindery", "Ashy-skeletal over loamy-skeletal", "Ashy-skeletal over sandy or sandy-skeletal", "Cindery over loamy", "Cindery over medial", "Cindery over medial-skeletal", "Clayey over coarse-gypseous", "Clayey over fine-gypseous", "Clayey over fragmental", "Clayey over gypseous-skeletal", "Clayey over loamy", "Clayey over loamy-skeletal", "Clayey over sandy or sandy-skeletal", "Clayey-skeletal over sandy or sandy-skeletal", "Coarse-loamy over clayey", "Coarse-loamy over fragmental", "Coarse-loamy over sandy or sandy-skeletal", "Coarse-silty over clayey", "Coarse-silty over sandy or sandy-skeletal", "Fine-loamy over clayey", "Fine-loamy over fragmental", "Fine-loamy over sandy or sandy-skeletal", "Fine-silty over clayey", "Fine-silty over fragmental", "Fine-silty over sandy or sandy-skeletal", "Hydrous over clayey", "Hydrous over clayey-skeletal", "Hydrous over fragmental", "Hydrous over loamy", "Hydrous over loamy-skeletal", "Hydrous over sandy or sandy-skeletal", "Loamy over ashy or ashy-pumiceous", "Loamy over coarse-gypseous", "Loamy over fine-gypseous", "Loamy over pumiceous or cindery", "Loamy over sandy or sandy-skeletal", "Loamy-skeletal over cindery", "Loamy-skeletal over clayey", "Loamy-skeletal over fragmental", "Loamy-skeletal over gypseous-skeletal", "Loamy-skeletal over sandy or sandy-skeletal", "Medial over ashy", "Medial over ashy-pumiceous or ashy-skeletal", "Medial over clayey", "Medial over clayey-skeletal", "Medial over fragmental", "Medial over hydrous", "Medial over loamy", "Medial over loamy-skeletal", "Medial over pumiceous or cindery", "Medial over sandy or sandy-skeletal", "Medial-skeletal over fragmental or cindery", "Medial-skeletal over loamy-skeletal", "Medial-skeletal over sandy or sandy-skeletal", "Pumiceous or ashy-pumiceous over loamy", "Pumiceous or ashy-pumiceous over loamy-skeletal", "Pumiceous or ashy-pumiceous over medial", "Pumiceous or ashy-pumiceous over medial-skeletal", "Pumiceous or ashy-pumiceous over sandy or sandy-skeletal", "Sandy over clayey", "Sandy over loamy", "Sandy-skeletal over loamy")) diff --git a/man/hz_intersect.Rd b/man/hz_intersect.Rd index 304e85a7..6841ec1b 100644 --- a/man/hz_intersect.Rd +++ b/man/hz_intersect.Rd @@ -27,21 +27,19 @@ This function intersects two horizon tables by harmonizing their depths and merg \examples{ h <- data.frame( -id = 1, -top = c(0, 25, 44, 46, 50), -bottom = c(25, 44, 46, 50, 100), -by = c("Yes", "Yes", "No", "No", "Yes"), -clay = c(10, 12, 27, 35, 16) + id = 1, + top = c(0, 25, 44, 46, 50), + bottom = c(25, 44, 46, 50, 100), + by = c("Yes", "Yes", "No", "No", "Yes"), + clay = c(10, 12, 27, 35, 16) ) -h |> hz_dissolve("by") +hz_dissolve(h, "by") -h |> hz_dissolve("by") |> hz_intersect(x = _, y = h) +hz_intersect(x = hz_dissolve(h, "by"), y = h) -h |> -hz_dissolve("by") |> -hz_intersect(x = h, y = _) |> -aggregate(clay ~ dissolve_id, data = _, mean) +hi <- hz_intersect(x = h, y = hz_dissolve(h, "by")) +aggregate(clay ~ dissolve_id, data = hi, mean) } \seealso{ diff --git a/man/hz_lag.Rd b/man/hz_lag.Rd index 1691dc65..80c68819 100644 --- a/man/hz_lag.Rd +++ b/man/hz_lag.Rd @@ -45,18 +45,16 @@ texcl = c("SL", "SL", "CL", "CL", "L"), clay = c(10, 12, 27, 35, 16) ) -h |> hz_lag() +hz_lag(h) -h |> hz_lag(-1) +hz_lag(h, -1) -h |> hz_lag(10:15, unit = "depth") +hz_lag(h, 10:15, unit = "depth") -h |> -hz_lag() |> -cbind(h, lag = _) |> -transform( -clay_dif = lag.clay_bot.1 - clay, -texcl_contrast = paste0(texcl, "-", lag.texcl_bot.1)) +transform(cbind(h, lag = hz_lag(h)), + clay_dif = lag.clay_bot.1 - clay, + texcl_contrast = paste0(texcl, "-", lag.texcl_bot.1) +) } \seealso{ From 980f9e37d628ef3ebeecd5c31066bb6e102caf84 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Mon, 24 Jun 2024 16:01:47 -0700 Subject: [PATCH 2/5] Update R-CMD-check.yaml - try no-build/ignore vignettes on R 3.6 --- .github/workflows/R-CMD-check.yaml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 327613f7..53ec9786 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -34,10 +34,9 @@ jobs: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - + steps: - - uses: actions/checkout@v4 - + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} @@ -52,16 +51,9 @@ jobs: brew install --cask xquartz - uses: r-lib/actions/setup-r-dependencies@v2 - if: matrix.config.r == '3.6' with: extra-packages: any::rcmdcheck, soiltexture=?ignore-before-r=4.3.0, markovchain=?ignore-before-r=4.0.0, Hmisc=?ignore, knitr=?ignore-before-r=4.0.0, rmarkdown=?ignore-before-r=4.0.0, testthat=?ignore-before-r=4.0.0, needs: check - - - uses: r-lib/actions/setup-r-dependencies@v2 - if: matrix.config.r != '3.6' - with: - extra-packages: any::rcmdcheck, markovchain=?ignore-before-r=4.0.0 - needs: check - name: Install soilDB from r-universe (R-devel only) if: matrix.config.r == 'devel' @@ -70,6 +62,13 @@ jobs: shell: Rscript {0} - uses: r-lib/actions/check-r-package@v2 + if: matrix.config.r != '3.6' + with: + upload-snapshots: true + + - uses: r-lib/actions/check-r-package@v2 + if: matrix.config.r == '3.6' with: + args: 'c("--no-manual", "--as-cran", "--no-build-vignettes", "--ignore-vignettes")' upload-snapshots: true From b69fc3dbc7c84d209b7c1db30b38b0c920d21f09 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Mon, 24 Jun 2024 16:14:08 -0700 Subject: [PATCH 3/5] Update R-CMD-check.yaml - try `--no-build-vignettes` in `build_args` --- .github/workflows/R-CMD-check.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 53ec9786..1a390ff0 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -69,6 +69,7 @@ jobs: - uses: r-lib/actions/check-r-package@v2 if: matrix.config.r == '3.6' with: - args: 'c("--no-manual", "--as-cran", "--no-build-vignettes", "--ignore-vignettes")' + args: 'c("--no-manual", "--as-cran", "--ignore-vignettes")' + build_args: 'c("--no-manual", "--no-build-vignettes")' upload-snapshots: true From d35e601eb36f299dac667a2e79d4c79ae5505207 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Mon, 24 Jun 2024 16:21:08 -0700 Subject: [PATCH 4/5] Update R-CMD-check.yaml - add `--no-tests` to check args for R 3.6 --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 1a390ff0..caab4019 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -69,7 +69,7 @@ jobs: - uses: r-lib/actions/check-r-package@v2 if: matrix.config.r == '3.6' with: - args: 'c("--no-manual", "--as-cran", "--ignore-vignettes")' + args: 'c("--no-manual", "--as-cran", "--ignore-vignettes", "--no-tests")' build_args: 'c("--no-manual", "--no-build-vignettes")' upload-snapshots: true From 085d4bdd049fa8301c153d1ec1dbf87b6c47113b Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Tue, 25 Jun 2024 10:16:48 -0700 Subject: [PATCH 5/5] whitespace, syntax formatting, fix deprecation messages --- R/allocate.R | 131 +++++++++++++++++++-------------------- R/segment.R | 104 +++++++++++++------------------ man/hz_lag.Rd | 10 +-- man/hz_to_taxpartsize.Rd | 43 ++++++------- 4 files changed, 130 insertions(+), 158 deletions(-) diff --git a/R/allocate.R b/R/allocate.R index 908d1547..673d4aef 100644 --- a/R/allocate.R +++ b/R/allocate.R @@ -662,38 +662,32 @@ allocate <- function(..., to = c("FAO Salt Severity", "FAO Black Soil", "ST Diag #' @seealso [texture_to_taxpartsize()], [lookup_taxpartsize()] #' #' @export - #' @examples #' #' h <- data.frame( -#' id = 1, -#' hzname = c("A", "BA", "Bw", "BC", "C"), -#' top = c( 0, 10, 45, 60, 90), -#' bottom = c(10, 45, 60, 90, 150), -#' clay = c(15, 16, 45, 20, 10), -#' sand = c(10, 35, 40, 50, 90), -#' frags = c( 0, 5, 10, 38, 40) -#' ) -#' -#' h <- cbind( -#' h, -#' texcl = ssc_to_texcl(clay = h$clay, sand = h$sand) +#' id = 1, +#' hzname = c("A", "BA", "Bw", "BC", "C"), +#' top = c(0, 10, 45, 60, 90), +#' bottom = c(10, 45, 60, 90, 150), +#' clay = c(15, 16, 45, 20, 10), +#' sand = c(10, 35, 40, 50, 90), +#' frags = c(0, 5, 10, 38, 40) #' ) #' -#' pscs <- data.frame( -#' id = 1, -#' top = 25, -#' bottom = 100 -#' ) +#' h <- cbind(h, +#' texcl = ssc_to_texcl(clay = h$clay, sand = h$sand)) +#' +#' pscs <- data.frame(id = 1, +#' top = 25, +#' bottom = 100) #' -#' h <- cbind( -#' h, -#' taxpartsize = texture_to_taxpartsize( -#' texcl = h$texcl, -#' clay = h$clay, -#' sand = h$sand, -#' fragvoltot = h$frags -#' )) +#' h <- cbind(h, +#' taxpartsize = texture_to_taxpartsize( +#' texcl = h$texcl, +#' clay = h$clay, +#' sand = h$sand, +#' fragvoltot = h$frags +#' )) #' #' depths(h) <- id ~ top + bottom #' @@ -713,7 +707,6 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", # xy <- hz_intersect(x, y, idcol = idcol, depthcols = depthcols) # x_sub <- x[x$rn %in% xy$rn, ] - # check segment_id ---- ## if it exists, overwrite it x_nm <- names(x) @@ -723,7 +716,6 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", y[y_nm == "segment_id"] <- NULL } - # check dissolve_id ---- ## if it exists, overwrite it x_nm <- names(x) @@ -733,7 +725,6 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", y[y_nm == "dissolve_id"] <- NULL } - # standardize inputs ---- vars <- c(idcol, depthcols, clay, taxpartsize) x <- x[vars] @@ -744,24 +735,27 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", y <- y[c(idcol, depthcols)] y <- .standardize_inputs(y, idcol = idcol, depthcols = depthcols)$x - # dissolve on pscs ---- # calculate non-trimmed horizon thickness - x_dis <- transform(hz_dissolve(x, by = "taxpartsize", idcol = "idcol", depthcols = c("top", "bot")), + x_dis <- transform(hz_dissolve(x, + by = "taxpartsize", + idcol = "idcol", + depthcols = c("top", "bot")), thk_o = bot - top) - # trim depths ---- # calculate trimmed horizon thickness - xy_dis <- transform(hz_intersect(x_dis, y, idcol = "idcol", depthcols = c("top", "bot")), + xy_dis <- transform(hz_intersect(x_dis, y, + idcol = "idcol", + depthcols = c("top", "bot")), thk_t = bot - top) - # rejoin dissolved pscs to the original horizon table ---- - xy <- suppressWarnings(hz_intersect(x, xy_dis, idcol = "idcol", depthcols = c("top", "bot"))) + xy <- suppressWarnings(hz_intersect(x, xy_dis, + idcol = "idcol", + depthcols = c("top", "bot"))) x_dis <- NULL xy_dis <- NULL - # aggregate clay values within dissolved pscs ---- top <- NULL @@ -775,7 +769,7 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", list( top = min(top, na.rm = TRUE), bot = max(bot, na.rm = TRUE), - clay_wt = weighted.mean(clay, w = thk_t, na.rm = TRUE), + clay_wt = weighted.mean(clay, w = thk_t, na.rm = TRUE), # sandvf_wt = weighted.mean(sandvf, w = thk_t, na.rm = TRUE), # need to impute frags # frag_wt = weighted.mean(total_frags_pct_nopf, w = thk_t), na.rm = TRUE, @@ -786,19 +780,18 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", data.table::setorder(xy_agg, idcol, top) xy_agg <- as.data.frame(xy_agg) - # find adjacent horizons ---- xy_lag <- hz_lag(xy_agg, idcol = "idcol", depthcols = c("top", "bot")) - # address special cases of strongly contrasting classes ---- clay_wt_bot.1 <- NULL sandvf_wt_bot.1 <- NULL taxpartsize_bot.1 <- NULL - # still needs special cases for very fine sand - xy_agg <- within(cbind(xy_agg, xy_lag), { + xy_agg <- within( + cbind(xy_agg, xy_lag), + { clay_dif = clay_wt_bot.1 - clay_wt sc = paste0(taxpartsize, " over ", taxpartsize_bot.1) sc = gsub(" over NA$", "", sc) @@ -847,54 +840,58 @@ hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", # ) # idx_sc = grepl("over", sc) sc = ifelse(idx_sc, sc, taxpartsize) - }) + } + ) xy_lag <- NULL - # find multiple strongly contrasting ps classes within the control section n_sc <- NULL n_peiid <- NULL - test <- as.data.frame(data.table::as.data.table(xy_agg)[, list( - n_sc = sum(idx_sc, na.rm = TRUE), # sum(grepl(" over ", sc), na.rm = TRUE), - n_peiid = length(idx_sc) - ), - by = "idcol" - ]) - + test <- as.data.frame(data.table::as.data.table(xy_agg)[, + list(n_sc = sum(idx_sc, na.rm = TRUE), + # sum(grepl(" over ", sc), na.rm = TRUE), + n_peiid = length(idx_sc)), + by = "idcol"]) # pick the sc pscs with the largest contrast or pscs with the greatest thickness - xy_res <- transform(merge(xy_agg, test, by = "idcol", all.x = TRUE, sort = FALSE), + xy_res <- transform( + merge( + xy_agg, + test, + by = "idcol", + all.x = TRUE, + sort = FALSE + ), idx_sc = sc %in% .pscs_sc, # idx_sc = grepl(" over ", sc), idx_c_ov_l = sc %in% c("clayey over fine-loamy") ) - xy_res <- - within(as.data.frame( - data.table::as.data.table(xy_res)[, list( + xy_res <- within(as.data.frame( + data.table::as.data.table(xy_res)[ , + list( pscs1 = sc[n_sc == 0 & n_peiid == 1], pscs2 = sc[n_sc == 1 & n_peiid > 1 & idx_sc], pscs3 = sc[which.max(thk_t[n_sc == 0 & n_peiid > 1])], pscs4 = sc[n_sc == 1 & idx_sc], pscs5 = sc[which.max(abs(clay_dif[n_sc > 1 & !is.na(sc)]))], taxpartsizemod = ifelse(max(n_sc) > 1, "aniso", "not used") - ), by = "idcol"]), - { - # need to add fix for special case of sandy over loamy which requires fine sand percent - taxpartsize = paste(pscs1, pscs3, pscs4, pscs5, sep = "") - taxpartsize = gsub("NA", "", taxpartsize) - pscs1 = NULL - pscs2 = NULL - pscs3 = NULL - pscs4 = NULL - pscs5 = NULL - }) - + ), + by = "idcol"]), + { + # need to add fix for special case of sandy over loamy which requires fine sand percent + taxpartsize = paste(pscs1, pscs3, pscs4, pscs5, sep = "") + taxpartsize = gsub("NA", "", taxpartsize) + pscs1 = NULL + pscs2 = NULL + pscs3 = NULL + pscs4 = NULL + pscs5 = NULL + }) # reset inputs xy_res <- .reset_inputs(xy_res, x_conv[1]) - return(xy_res) } diff --git a/R/segment.R b/R/segment.R index 7d7a86bc..dde1aefd 100644 --- a/R/segment.R +++ b/R/segment.R @@ -113,19 +113,17 @@ hz_segment <- function(object, intervals, trim = TRUE, depthcols = c("top", "bot bot = intervals[-1], stringsAsFactors = FALSE ) + n <- max(nchar(intervals)) - dep$id <- paste0( - formatC(dep$top, width = n, flag = 0), - "-", - formatC(dep$bot, width = n, flag = 0) - ) + dep$id <- paste0(formatC(dep$top, width = n, flag = 0), + "-", + formatC(dep$bot, width = n, flag = 0)) # argument sanity check ---- test_spc <- inherits(object, 'SoilProfileCollection') test_df <- inherits(object, 'data.frame') test_dep <- is.numeric(dep$top) & is.numeric(dep$bot) & all(dep$top < dep$bot) - if (!any(test_spc, test_df)) { stop("the input must be either a SoilProfileCollection or data.frame") } @@ -136,7 +134,6 @@ hz_segment <- function(object, intervals, trim = TRUE, depthcols = c("top", "bot stop("intervals should be numeric and sequential (e.g. c(0, 1, 2, 3) or 0:100)") } - # standardize inputs ---- if (test_spc) { idcol <- idname(object) @@ -149,7 +146,6 @@ hz_segment <- function(object, intervals, trim = TRUE, depthcols = c("top", "bot } names(h)[names(h) %in% depthcols] <- c("top", "bot") - ## TODO: consider using dice() # filter horizons and trim ---- .slice <- function(h, top = NULL, bot = NULL) { @@ -164,7 +160,7 @@ hz_segment <- function(object, intervals, trim = TRUE, depthcols = c("top", "bot # h <- h[(h$bot - h$top) > 0, ] } - # h <- h[!is.na(h$peiid), ] + # h <- h[!is.na(h$peiid), ] return(h) } @@ -174,14 +170,17 @@ hz_segment <- function(object, intervals, trim = TRUE, depthcols = c("top", "bot df_str <- cbind(h[0, ], segment_id = NA_character_[0]) dep$df <- list(df_str)[rep(1, nrow(dep))] # pre-allocate memory faster h <- { - split(dep, dep$id) ->.; + split(dep, dep$id) -> . + lapply(., function(x) { temp <- .slice(h, top = x$top, bot = x$bot) - if (nrow(temp) > 0) x$df[[1]] <- cbind(temp, segment_id = x$id) + if (nrow(temp) > 0) + x$df[[1]] <- cbind(temp, segment_id = x$id) return(x$df[[1]]) - }) ->.; - do.call("rbind", .) ->.; - } + }) -> . + + do.call("rbind", .) -> . + } names(h)[names(h) %in% c("top", "bot")] <- depthcols @@ -216,12 +215,10 @@ hz_segment <- function(object, intervals, trim = TRUE, depthcols = c("top", "bot #' @export #' @rdname hz_segment segment <- function(object, intervals, trim = TRUE, hzdepcols = c("top", "bottom")) { - .Deprecated("segment() will be deprecated and replaced by hz_segment()") + .Deprecated("segment() is deprecated and has been replaced by hz_segment()") hz_segment(object, intervals, trim, depthcols = hzdepcols) } - - #' @title Dissolving horizon boundaries by grouping variables #' #' @description This function dissolves or combines horizons that have a common set of grouping variables. It only combines those horizon records that are sequential (e.g. share a horizon boundary). Thus, it can be used to identify discontinuities in the grouping variables along a profile and their unique depths. It is particularly useful for determining the depth to the top or bottom of horizons with a specific category, and should be simpler than previous methods that require aggregating over profiles. @@ -281,8 +278,6 @@ segment <- function(object, intervals, trim = TRUE, hzdepcols = c("top", "bottom #' test <- hz_dissolve(df, "genhz") #' subset(test, value == "2Bt") #' - - hz_dissolve <- function(object, by, idcol = "id", depthcols = c("top", "bottom"), collapse = FALSE, order = FALSE) { # id = "peiid"; hztop = "hzdept"; hzbot = "hzdepb", collapse = FALSE, order = FALSE @@ -296,29 +291,24 @@ hz_dissolve <- function(object, by, idcol = "id", depthcols = c("top", "bottom") if (!any(test_object)) { stop("the object argument must be a data.frame", call. = FALSE) } - # check that collapse is a logical of length 1 if (!inherits(collapse, "logical") || length(collapse) != 1) { stop("the collapse argument must be logical and a length of one", call. = FALSE) } - # check that by is not NULL if (is.null(by)) stop("the by argument must not be NULL") - # check that "by" are characters or convert if (any(!"character" %in% sapply(object[by], class))) { message("non-character grouping variables are being converted to characters") object[by] <- lapply(object[by], as.character) } - # check that the column names exist within the object .check_names(object, vars = c(idcol = idcol, top = depthcols[1], bot = depthcols[2], by)) - # check if previous dissolve_id exists and overwrite nm <- names(object) idx <- nm == "dissolve_id" @@ -327,7 +317,6 @@ hz_dissolve <- function(object, by, idcol = "id", depthcols = c("top", "bottom") object[idx] <- NULL } - # standardize inputs ---- df_std <- .standardize_inputs(object, idcol = idcol, depthcols = depthcols) df_conversion <- df_std$x_conversion @@ -346,7 +335,6 @@ hz_dissolve <- function(object, by, idcol = "id", depthcols = c("top", "bottom") by <- by_co } - # var thickness ---- var_dep <- lapply(by, function(x) { @@ -381,7 +369,6 @@ hz_dissolve <- function(object, by, idcol = "id", depthcols = c("top", "bottom") # ) # } - # append dissolve_id n <- max(nchar(c(var_dep$top, var_dep$bot)), na.rm = TRUE) @@ -407,9 +394,9 @@ hz_dissolve <- function(object, by, idcol = "id", depthcols = c("top", "bottom") #' @rdname hz_dissolve dissolve_hz <- function(object, by, id = "idcol", hztop = "top", hzbot = "bottom", collapse = FALSE, order = FALSE) { - .Deprecated("dissolve_hz() will be deprecated and replaced by hz_dissolve()") + .Deprecated("dissolve_hz() is deprecated and has been replaced by hz_dissolve()") hz_dissolve(object, by, idcol = id, depthcols = c(hztop, hzbot), collapse, order) - } +} @@ -462,7 +449,6 @@ hz_intersect <- function(x, y, idcol = "id", depthcols = c("top", "bottom")) { .check_names(x, c(idcol, depthcols)) .check_names(y, c(idcol, depthcols)) - # check segment_id ---- ## if it exists, overwrite it x_nm <- names(x) @@ -477,7 +463,6 @@ hz_intersect <- function(x, y, idcol = "id", depthcols = c("top", "bottom")) { y[y_nm == "segment_id"] <- NULL } - # standardize inputs ---- x_std <- .standardize_inputs(x, idcol = idcol, depthcols = depthcols) x_conversion <- x_std$x_conversion @@ -486,8 +471,7 @@ hz_intersect <- function(x, y, idcol = "id", depthcols = c("top", "bottom")) { y <- .standardize_inputs(y, idcol = idcol, depthcols = depthcols)$x # intersect x & y ---- - split(x, x$idcol) ->.; - lapply(., function(x) { + res <- lapply(split(x, x$idcol), function(x) { xi <- x yi <- y[which(y$idcol == xi$idcol[1]), ] @@ -500,21 +484,18 @@ hz_intersect <- function(x, y, idcol = "id", depthcols = c("top", "bottom")) { return(list(x_seg = xi_seg, y_seg = yi_seg)) } - }) ->.; - + }) - x_seg <- do.call("rbind", lapply(., function(x) x[["x_seg"]])) - y_seg <- do.call("rbind", lapply(., function(x) x[["y_seg"]])) - + x_seg <- do.call("rbind", lapply(res, function(x) x[["x_seg"]])) + y_seg <- do.call("rbind", lapply(res, function(x) x[["y_seg"]])) xy_int <- merge(x_seg, y_seg, by = c("segment_id", "idcol", "top", "bot"), sort = FALSE) - # reset inputs ---- xy_int <- .reset_inputs(xy_int, x_conversion) return(xy_int) - } +} @@ -541,11 +522,11 @@ hz_intersect <- function(x, y, idcol = "id", depthcols = c("top", "bottom")) { #' @examples #' #' h <- data.frame( -#' id = 1, -#' top = c(0, 25, 44, 46, 50), -#' bottom = c(25, 44, 46, 50, 100), -#' texcl = c("SL", "SL", "CL", "CL", "L"), -#' clay = c(10, 12, 27, 35, 16) +#' id = 1, +#' top = c(0, 25, 44, 46, 50), +#' bottom = c(25, 44, 46, 50, 100), +#' texcl = c("SL", "SL", "CL", "CL", "L"), +#' clay = c(10, 12, 27, 35, 16) #' ) #' #' hz_lag(h) @@ -565,17 +546,15 @@ hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c( idx_std <- which(! nm %in% c(idcol, depthcols)) vars <- nm[idx_std] - # check arguments ---- .check_depthcols_l(depthcols) .check_names(object, vars = c(idcol, depthcols, vars)) - # standardize inputs ---- x_std <- .standardize_inputs(object, idcol = idcol, depthcols = depthcols) x_conversion <- x_std$x_conversion - x <- x_std$x; rm(x_std) - + x <- x_std$x + rm(x_std) # check depths --- if (unit == "depth" & max(object[[depthcols[2]]] > 1000)) { @@ -590,13 +569,11 @@ hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c( } } - # order ---- if (order) { x <- x[order(x$idcol, x$top, x$bot), ] } - # lag ---- .lag_ind <- function(x, lag = lag) { @@ -614,7 +591,6 @@ hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c( return(x_lag) } - .lag_dep <- function(x, lag = lag) { n <- length(x) @@ -622,7 +598,6 @@ hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c( x_seg <- hz_segment(x, intervals = min(x$top):max(x$bot), trim = TRUE, depthcols = c("top", "bot")) x_seg <- x_seg[1:(n + 1)] - x_seg <- do.call("cbind", args = lapply(lag, function(i) { x$bot_i <- x$bot + i idx <- match(paste(x$idcol, x$bot_i), @@ -643,7 +618,6 @@ hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c( return(x_seg) } - if (unit == "index") { x_lag <- do.call("cbind", lapply(lag, function(i) { .lag_ind(x, i) @@ -662,27 +636,31 @@ hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c( return(x_lag) } - - # check depthcols length .check_depthcols_l <- function(x) { if (length(x) != 2 & !is.null(x)) stop("depthcols must length must equal 2") } - ## check for matching column names .check_names <- function(x, vars) { - x_nm <- names(x) - if (! all(vars %in% x_nm)) { + if (!all(vars %in% x_nm)) { stop("x must contain columns with names that match the input arguments") } } - # standardize inputs -.standardize_inputs <- function(x, idcol = NULL, hzidcol = NULL, depthcols = NULL, texcl = NULL, clay = NULL, taxpartsize = NULL, sand = NULL) { +.standardize_inputs <- function( + x, + idcol = NULL, + hzidcol = NULL, + depthcols = NULL, + texcl = NULL, + clay = NULL, + taxpartsize = NULL, + sand = NULL +) { # set new names var_names <- c( @@ -711,7 +689,9 @@ hz_lag <- function(object, lag = 1, unit = "index", idcol = "id", depthcols = c( idx_orig <- idx_dup[! idx_dup %in% idx_x] names(x)[idx_orig] <- paste0(names(x)[idx_orig], "_orig") - } else idx_orig = NULL + } else { + idx_orig <- NULL + } return(list(x = x, x_conversion = var_names, x_orig = idx_orig)) } diff --git a/man/hz_lag.Rd b/man/hz_lag.Rd index 80c68819..4acb253b 100644 --- a/man/hz_lag.Rd +++ b/man/hz_lag.Rd @@ -38,11 +38,11 @@ This function finds adjacent values to a horizon values at lagged distances. \examples{ h <- data.frame( -id = 1, -top = c(0, 25, 44, 46, 50), -bottom = c(25, 44, 46, 50, 100), -texcl = c("SL", "SL", "CL", "CL", "L"), -clay = c(10, 12, 27, 35, 16) + id = 1, + top = c(0, 25, 44, 46, 50), + bottom = c(25, 44, 46, 50, 100), + texcl = c("SL", "SL", "CL", "CL", "L"), + clay = c(10, 12, 27, 35, 16) ) hz_lag(h) diff --git a/man/hz_to_taxpartsize.Rd b/man/hz_to_taxpartsize.Rd index 2daefdf8..8a477fd2 100644 --- a/man/hz_to_taxpartsize.Rd +++ b/man/hz_to_taxpartsize.Rd @@ -38,34 +38,29 @@ This function differs from \code{\link{texture_to_taxpartsize}} in that is aggre \examples{ h <- data.frame( -id = 1, -hzname = c("A", "BA", "Bw", "BC", "C"), -top = c( 0, 10, 45, 60, 90), -bottom = c(10, 45, 60, 90, 150), -clay = c(15, 16, 45, 20, 10), -sand = c(10, 35, 40, 50, 90), -frags = c( 0, 5, 10, 38, 40) + id = 1, + hzname = c("A", "BA", "Bw", "BC", "C"), + top = c(0, 10, 45, 60, 90), + bottom = c(10, 45, 60, 90, 150), + clay = c(15, 16, 45, 20, 10), + sand = c(10, 35, 40, 50, 90), + frags = c(0, 5, 10, 38, 40) ) -h <- cbind( -h, -texcl = ssc_to_texcl(clay = h$clay, sand = h$sand) -) +h <- cbind(h, + texcl = ssc_to_texcl(clay = h$clay, sand = h$sand)) -pscs <- data.frame( -id = 1, -top = 25, -bottom = 100 -) +pscs <- data.frame(id = 1, + top = 25, + bottom = 100) -h <- cbind( -h, -taxpartsize = texture_to_taxpartsize( -texcl = h$texcl, -clay = h$clay, -sand = h$sand, -fragvoltot = h$frags -)) +h <- cbind(h, + taxpartsize = texture_to_taxpartsize( + texcl = h$texcl, + clay = h$clay, + sand = h$sand, + fragvoltot = h$frags + )) depths(h) <- id ~ top + bottom