Skip to content
Snippets Groups Projects
Commit 048dbe13 authored by Christoph Schürz's avatar Christoph Schürz
Browse files

Replace random sampling in name trimming in update_landuse_labels

parent 7aa348a0
No related branches found
No related tags found
No related merge requests found
Package: SWATdoctR
Type: Package
Title: Finding the right diagnoses and treatments for SWAT+ models
Version: 0.1.20
Version: 0.1.21
Author: c(person("Christoph", "Schürz",
email = "christoph.schuerz@ufz.de",
role = c("aut", "cre")),
......
......@@ -153,8 +153,13 @@ remove_consonants <- function(tbl) {
n <- tbl$n_chr[1] - 12
txt_split <- str_split(tbl$lu_mgt_upd[1], '', simplify = TRUE)
alph_pos <- which(str_detect(txt_split, '[:alpha:]'))
pos_rmv <- sample(alph_pos[alph_pos > 1], n)
txt <- paste(txt_split[-pos_rmv], collapse = '')
pos_rmv <- seq(2, length(alph_pos), 2)
pos_rmv <- pos_rmv[1:min(length(pos_rmv), n)]
if (length(pos_rmv) < n) {
n_diff <- n - length(pos_rmv)
pos_rmv <- c(pos_rmv, seq(3, length(alph_pos), length.out = n_diff))
}
txt <- paste(txt_split[-alph_pos[pos_rmv]], collapse = '')
tbl$lu_mgt_upd <- txt
}
return(tbl)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment