From 95e8cb4ed63d40ce91dbb5b8cc67a9164f774932 Mon Sep 17 00:00:00 2001 From: Roe <12001003012275@FEDIDCARD.GOV> Date: Fri, 29 Nov 2024 23:32:19 -0800 Subject: [PATCH 1/2] Add basal area tables. --- R/get_NASIS_table_name_by_purpose.R | 59 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/R/get_NASIS_table_name_by_purpose.R b/R/get_NASIS_table_name_by_purpose.R index 90be3e65..4d052f52 100644 --- a/R/get_NASIS_table_name_by_purpose.R +++ b/R/get_NASIS_table_name_by_purpose.R @@ -1,7 +1,7 @@ -#' Get NASIS 7 Physical Table Names -#' +#' Get NASIS 7 Physical Table Names +#' #' Method generalizing concepts of NASIS 7 data model to group tables by "purpose." Most of our more complex queries rely on tables from one or more purposes, so individual higher-level functions might call a function like this to identify the relevant tables from a data source. -#' +#' #' @param purpose character. One or more of: "metadata", "lookup", "nasis", "site", "pedon", "transect", "component", "vegetation", "project", "techsoilservice", "area", "soilseries", "legend", "mapunit", "datamapunit" #' @param SS append "_View_1" on appropriate tables? Default: FALSE #' @@ -12,30 +12,30 @@ #' \dontrun{ #' # get the "site" table names #' get_NASIS_table_name_by_purpose("site") -#' +#' #' # get the pedon table names #' get_NASIS_table_name_by_purpose("pedon", SS = TRUE) -#' +#' #' # metadata and lookup not affected by SS argument, but site and pedon are #' get_NASIS_table_name_by_purpose(c("metadata", "lookup", #' "site", "pedon"), SS = TRUE) #' } -#' -get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "nasis", "site", - "pedon", "transect", "component", - "vegetation", "project", +#' +get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "nasis", "site", + "pedon", "transect", "component", + "vegetation", "project", "techsoilservice", "area", "soilseries", "legend", "mapunit", "datamapunit"), SS = FALSE) { - + # TODO: store as .rda? table_groups <- list( metadata = c( "MetadataDomainDetail", "MetadataDomainMaster", - "MetadataTableColumn", - "MetadataTable", + "MetadataTableColumn", + "MetadataTable", "MetadataColumnLookup", "MetadataIndexDetail" ), @@ -118,7 +118,7 @@ get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "n component = c( "component", "chorizon", - "chfrags", + "chfrags", "chhuarts", "chtexturegrp", "chstructgrp", @@ -168,7 +168,8 @@ get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "n "comparativeyielddata", "comparativeyieldrefquadrats", "pointplantcoverdetails", - "plantprodquadratdetails" + "plantprodquadratdetails", + "plotspeciesbasalarea" ), project = c( "project", @@ -202,33 +203,33 @@ get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "n datamapunit = "datamapunit", nasis = c("nasisgroup", "nasisuser") ) - - uses_View_1 <- list("metadata" = FALSE, - "lookup" = FALSE, - "site" = TRUE, - "pedon" = TRUE, - "transect" = TRUE, - "component" = TRUE, + + uses_View_1 <- list("metadata" = FALSE, + "lookup" = FALSE, + "site" = TRUE, + "pedon" = TRUE, + "transect" = TRUE, + "component" = TRUE, "vegetation" = TRUE, "project" = TRUE, - "techsoilservice" = TRUE, + "techsoilservice" = TRUE, "area" = TRUE, "soilseries" = FALSE, - "legend" = TRUE, - "mapunit" = TRUE, + "legend" = TRUE, + "mapunit" = TRUE, "datamapunit" = TRUE, "nasis" = FALSE) - + purpose <- match.arg(purpose, names(table_groups), several.ok = TRUE) - + res <- table_groups[purpose] - + res <- lapply(seq_along(res), function(i) { ni <- names(res)[i] - if (uses_View_1[[ni]] && SS) + if (uses_View_1[[ni]] && SS) return(paste0(res[[ni]], "_View_1")) else return(res[[ni]]) }) - + return(as.character(unlist(res))) } From 9c4b028178becab14ae465feef6100788f956ed4 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Mon, 2 Dec 2024 16:30:14 -0800 Subject: [PATCH 2/2] Update R/get_NASIS_table_name_by_purpose.R --- R/get_NASIS_table_name_by_purpose.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/get_NASIS_table_name_by_purpose.R b/R/get_NASIS_table_name_by_purpose.R index 4d052f52..35239e29 100644 --- a/R/get_NASIS_table_name_by_purpose.R +++ b/R/get_NASIS_table_name_by_purpose.R @@ -169,7 +169,8 @@ get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "n "comparativeyieldrefquadrats", "pointplantcoverdetails", "plantprodquadratdetails", - "plotspeciesbasalarea" + "plotspeciesbasalarea", + "basalareatreescounted" ), project = c( "project",