Skip to content

Commit

Permalink
CRAN Release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Jul 13, 2022
1 parent ba196c2 commit b8d8e3f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
^Meta$
^README\.Rmd$
^data-raw$
^CRAN-SUBMISSION$
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LazyLoad: yes
Repository: CRAN
URL: https://github.com/ncss-tech/SoilTaxonomy, https://ncss-tech.github.io/SoilTaxonomy/
BugReports: https://github.com/ncss-tech/SoilTaxonomy/issues
Imports: stringr, data.table
Imports: stats, utils, stringr, data.table
Suggests:
testthat,
covr,
Expand Down
12 changes: 7 additions & 5 deletions R/family-classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ parse_family <- function(family, column_metadata = TRUE, flat = TRUE) {
ColumnPhysicalName = md$ColumnPhysicalName[match(x$classname, md$ChoiceName)],
stringsAsFactors = FALSE
))
cbind(`colnames<-`(as.data.frame(t(res5[[1]]), stringsAsFactors = FALSE), res5[[2]]), taxsub[i, ])
cbind(stats::setNames(as.data.frame(t(res5[[1]]), stringsAsFactors = FALSE), res5[[2]]), taxsub[i, ])
})

allowed.names <- c("taxpartsize", "taxpartsizemod",
Expand All @@ -153,7 +153,7 @@ parse_family <- function(family, column_metadata = TRUE, flat = TRUE) {
"taxfamhahatmatcl", "taxfamother",
"taxsubgrp", "taxgrtgroup",
"taxsuborder", "taxorder")
basetbl <- as.data.frame(`names<-`(rep(list(numeric(0)), length(allowed.names)), allowed.names), stringsAsFactors = FALSE)
basetbl <- as.data.frame(stats::setNames(rep(list(numeric(0)), length(allowed.names)), allowed.names), stringsAsFactors = FALSE)

# many:1, since we know these were previously comma-separated we re-concatenate with comma
# TODO: the algorithm does not currently try to separate and re-parse " over " type logic
Expand All @@ -169,19 +169,21 @@ parse_family <- function(family, column_metadata = TRUE, flat = TRUE) {
if (flat) {
.FUN <- .flat_FUN
}
.SD <- NULL

res5[multi.names] <- lapply(multi.names, function(n) {
res6 <- apply(data.frame(res5[names(res5) %in% n]), 1, .FUN)
res6 <- lapply(res6, function(nn) {
nnn <- nn[[1]]
lr6 <- length(nnn)
`names<-`(nnn, paste0(rep(n, lr6), seq_len(lr6)))
stats::setNames(nnn, paste0(rep(n, lr6), seq_len(lr6)))
})
if (flat) return(as.character(res6))
res6
})
out <- res5[allowed.names]
out <- type.convert(out[allowed.names], as.is = TRUE)
out <- utils::type.convert(out[allowed.names], as.is = TRUE)

# TODO: generalize if needed
if (!flat) {
out$taxminalogy <- I(res5$taxminalogy)
out$taxfamother <- I(res5$taxfamother)
Expand Down
2 changes: 1 addition & 1 deletion vignettes/family-level_taxonomy.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ data("ST_family_classes")
head(ST_family_classes)
```

Here we determine the family-level classes for a single taxonomic family and match them to the class descriptions stored in `ST_family_classes` using `get_ST_family_classes()`. Here we set `parse_family(..., column_metadata=FALSE)` to _not_ parse family components into corresponding NASIS domains (requires soilDB).
Here we determine the family-level classes for a single taxonomic family and match them to the class descriptions stored in `ST_family_classes` using `get_ST_family_classes()`. We set `parse_family(..., column_metadata=FALSE)` to _not_ parse family components into corresponding NASIS domains (requires soilDB).

```{r}
f <- "fine-loamy, mixed, semiactive, mesic ultic haploxeralfs"
Expand Down

0 comments on commit b8d8e3f

Please sign in to comment.