|
1 |
| -#' Get NASIS 7 Physical Table Names |
2 |
| -#' |
| 1 | +#' Get NASIS 7 Physical Table Names |
| 2 | +#' |
3 | 3 | #' 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.
|
4 |
| -#' |
| 4 | +#' |
5 | 5 | #' @param purpose character. One or more of: "metadata", "lookup", "nasis", "site", "pedon", "transect", "component", "vegetation", "project", "techsoilservice", "area", "soilseries", "legend", "mapunit", "datamapunit"
|
6 | 6 | #' @param SS append "_View_1" on appropriate tables? Default: FALSE
|
7 | 7 | #'
|
|
12 | 12 | #' \dontrun{
|
13 | 13 | #' # get the "site" table names
|
14 | 14 | #' get_NASIS_table_name_by_purpose("site")
|
15 |
| -#' |
| 15 | +#' |
16 | 16 | #' # get the pedon table names
|
17 | 17 | #' get_NASIS_table_name_by_purpose("pedon", SS = TRUE)
|
18 |
| -#' |
| 18 | +#' |
19 | 19 | #' # metadata and lookup not affected by SS argument, but site and pedon are
|
20 | 20 | #' get_NASIS_table_name_by_purpose(c("metadata", "lookup",
|
21 | 21 | #' "site", "pedon"), SS = TRUE)
|
22 | 22 | #' }
|
23 |
| -#' |
24 |
| -get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "nasis", "site", |
25 |
| - "pedon", "transect", "component", |
26 |
| - "vegetation", "project", |
| 23 | +#' |
| 24 | +get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "nasis", "site", |
| 25 | + "pedon", "transect", "component", |
| 26 | + "vegetation", "project", |
27 | 27 | "techsoilservice", "area",
|
28 | 28 | "soilseries", "legend",
|
29 | 29 | "mapunit", "datamapunit"),
|
30 | 30 | SS = FALSE) {
|
31 |
| - |
| 31 | + |
32 | 32 | # TODO: store as .rda?
|
33 | 33 | table_groups <- list(
|
34 | 34 | metadata = c(
|
35 | 35 | "MetadataDomainDetail",
|
36 | 36 | "MetadataDomainMaster",
|
37 |
| - "MetadataTableColumn", |
38 |
| - "MetadataTable", |
| 37 | + "MetadataTableColumn", |
| 38 | + "MetadataTable", |
39 | 39 | "MetadataColumnLookup",
|
40 | 40 | "MetadataIndexDetail"
|
41 | 41 | ),
|
@@ -118,7 +118,7 @@ get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "n
|
118 | 118 | component = c(
|
119 | 119 | "component",
|
120 | 120 | "chorizon",
|
121 |
| - "chfrags", |
| 121 | + "chfrags", |
122 | 122 | "chhuarts",
|
123 | 123 | "chtexturegrp",
|
124 | 124 | "chstructgrp",
|
@@ -168,7 +168,9 @@ get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "n
|
168 | 168 | "comparativeyielddata",
|
169 | 169 | "comparativeyieldrefquadrats",
|
170 | 170 | "pointplantcoverdetails",
|
171 |
| - "plantprodquadratdetails" |
| 171 | + "plantprodquadratdetails", |
| 172 | + "plotspeciesbasalarea", |
| 173 | + "basalareatreescounted" |
172 | 174 | ),
|
173 | 175 | project = c(
|
174 | 176 | "project",
|
@@ -202,33 +204,33 @@ get_NASIS_table_name_by_purpose <- function(purpose = c("metadata", "lookup", "n
|
202 | 204 | datamapunit = "datamapunit",
|
203 | 205 | nasis = c("nasisgroup", "nasisuser")
|
204 | 206 | )
|
205 |
| - |
206 |
| - uses_View_1 <- list("metadata" = FALSE, |
207 |
| - "lookup" = FALSE, |
208 |
| - "site" = TRUE, |
209 |
| - "pedon" = TRUE, |
210 |
| - "transect" = TRUE, |
211 |
| - "component" = TRUE, |
| 207 | + |
| 208 | + uses_View_1 <- list("metadata" = FALSE, |
| 209 | + "lookup" = FALSE, |
| 210 | + "site" = TRUE, |
| 211 | + "pedon" = TRUE, |
| 212 | + "transect" = TRUE, |
| 213 | + "component" = TRUE, |
212 | 214 | "vegetation" = TRUE,
|
213 | 215 | "project" = TRUE,
|
214 |
| - "techsoilservice" = TRUE, |
| 216 | + "techsoilservice" = TRUE, |
215 | 217 | "area" = TRUE,
|
216 | 218 | "soilseries" = FALSE,
|
217 |
| - "legend" = TRUE, |
218 |
| - "mapunit" = TRUE, |
| 219 | + "legend" = TRUE, |
| 220 | + "mapunit" = TRUE, |
219 | 221 | "datamapunit" = TRUE,
|
220 | 222 | "nasis" = FALSE)
|
221 |
| - |
| 223 | + |
222 | 224 | purpose <- match.arg(purpose, names(table_groups), several.ok = TRUE)
|
223 |
| - |
| 225 | + |
224 | 226 | res <- table_groups[purpose]
|
225 |
| - |
| 227 | + |
226 | 228 | res <- lapply(seq_along(res), function(i) {
|
227 | 229 | ni <- names(res)[i]
|
228 |
| - if (uses_View_1[[ni]] && SS) |
| 230 | + if (uses_View_1[[ni]] && SS) |
229 | 231 | return(paste0(res[[ni]], "_View_1"))
|
230 | 232 | else return(res[[ni]])
|
231 | 233 | })
|
232 |
| - |
| 234 | + |
233 | 235 | return(as.character(unlist(res)))
|
234 | 236 | }
|
0 commit comments