Skip to content

Commit

Permalink
fixing fetchNASIS(from = "pedon_report")
Browse files Browse the repository at this point in the history
uncode was set to use local db, now using the cached metadata file
  • Loading branch information
smroecker committed Jan 27, 2020
1 parent 6943b05 commit 348620d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/fetchNASIS_pedons.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# get NASIS site/pedon/horizon/diagnostic feature data
.fetchNASIS_pedons <- function(SS=TRUE, rmHzErrors=TRUE, nullFragsAreZero=TRUE, soilColorState='moist', lab=FALSE, stringsAsFactors = default.stringsAsFactors()) {

# test connection, should not be required, can be used if from = "pedon_report"
# test connection
if(! 'nasis_local' %in% names(RODBC::odbcDataSources()))
warning('Local NASIS ODBC connection has not been setup. Please see `http://ncss-tech.github.io/AQP/soilDB/setup_local_nasis.html`.')
stop('Local NASIS ODBC connection has not been setup. Please see `http://ncss-tech.github.io/AQP/soilDB/setup_local_nasis.html`.')

# sanity check
if(! soilColorState %in% c('dry', 'moist'))
Expand Down
6 changes: 3 additions & 3 deletions R/fetchNASIS_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# remove
x2 <- x2[!is.na(x2$peiid), - ncol(x2)]
idx <- names(x2) %in% c("pmkind", "pmorigin")
x2[!idx] <- uncode(x2[!idx])
x2[!idx] <- uncode(x2[!idx], db = "LIMS")
idx <- sapply(x2, is.character)
x2[idx] <- lapply(x2[idx], function(x) ifelse(x == "", NA, x))
return(x2)
Expand Down Expand Up @@ -154,7 +154,7 @@
# remove
temp = temp[!is.na(temp$peiid), - ncol(temp)]
idx = names(temp) %in% c("pmkind", "pmorigin")
temp[!idx] = uncode(temp[!idx])
temp[!idx] = uncode(temp[!idx], db = "LIMS")
idx = sapply(temp, is.character)
temp[idx] = lapply(temp[idx], function(x) ifelse(x == "", NA, x))
# temp = within(temp, {
Expand Down Expand Up @@ -193,7 +193,7 @@
# NASIS text reports return empty columns
# remove
temp = temp[!is.na(temp$peiid), - ncol(temp)]
temp = uncode(temp)
temp = uncode(temp, db = "LIMS")
# temp = within(temp, {
# obsdate = as.Date(as.character(obsdate))
# classdate = as.Date(as.character(classdate))
Expand Down

0 comments on commit 348620d

Please sign in to comment.