Skip to content

Commit

Permalink
fixed typo
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Jun 27, 2017
1 parent 1c6eabd commit 6e576a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 0 additions & 2 deletions R/fetchNASIS.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ fetchNASIS <- function(rmHzErrors=TRUE, nullFragsAreZero=TRUE, soilColorState='m
hz_data$total_frags_pct_cal <- ifelse(is.na(hz_data$total_frags_pct_cal), 0, hz_data$total_frags_pct_cal)
}


# join horizon + hz color: all horizons
h <- join(hz_data, color_data, by='phiid', type='left')

Expand Down Expand Up @@ -96,7 +95,6 @@ fetchNASIS <- function(rmHzErrors=TRUE, nullFragsAreZero=TRUE, soilColorState='m
assign("bad.horizons", value = data.frame(bad.horizons), envir = soilDB.env)
}


## join hz + phlabresults
if (lab) {
h <- join(h, phlabresults, by = "phiid", type = "left")
Expand Down
10 changes: 7 additions & 3 deletions R/simplfyFragmentData.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,16 @@ simplfyFragmentData <- function(rf, id.var, nullFragsAreZero=TRUE) {
lapply(rf.wide[, -1], function(i) ifelse(is.na(i), 0, i))
), stringsAsFactors=FALSE)
}


# compute total fragments
# trap no frag condition
if(ncol(rf.wide) > 1)
rf.wide$total_frags_pct <- rowSums(rf.wide[, -1], na.rm=TRUE)
if(ncol(rf.wide) > 1) {
#calculate another column for total RF, ignoring parafractions
rf.wide$total_frags_pct_nopf <- rowSums(rf.wide[,c(FALSE,!grepl(levels(rf.classes$class),pattern="para"))], na.rm=TRUE)

#calculate total fragments (including para)
rf.wide$total_frags_pct <- rowSums(rf.wide[, -c(1,length(names(rf.wide)))], na.rm=TRUE)
}

# corrections:
# 1. fine gravel is a subset of gravel, therefore: gravel = gravel + fine_gravel
Expand Down

1 comment on commit 6e576a4

@brownag
Copy link
Member Author

@brownag brownag commented on 6e576a4 Jun 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On branch 'Parafractions' simplifyFragmentData() outputs a dataframe with an additional column total_frags_pct_nopf. This is calculated in the same way as total_frags_pct omits the columns containing the "para"-fractions from the row sum calculation on the phfrags-derived dataframe.

Therefore, functions relying on fetchNASIS() or other functions that use simplifyFragmentData() will now have another variable available reflecting the parafragment-free totals.

Please sign in to comment.