Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
scaling up profileApply (#112)
profileApply operation now scales in execution time linearly rather than ~quadratically with increasing number of pedons in the collection over a range of typical to slightly larger than typical SoilProfileCollection (tens to hundreds of thousands)
Still need to consider optimization on
chunk.size
-- ~sqrt(length(spcobj))
-- sensitivity analysis suggests current default of100
is a good all around value for typical use.Before upgrade:
After "chunkApply" upgrade, 3x faster processing of 2000 pedons.
With
frameify = TRUE
:Here is definition of above used "simple" function that calculates horizon thickness and proportional thickness and returns an ID'd data.frame.
frameify
argument (#111)In the simplest sense,
frameify
combines list elements from the typical profileApply result into one large table. This presumes that the results from successive runs ofFUN
return adata.frame
with identical columns (or that can otherwise berbind
-ed)However, SoilProfileCollections contain several pieces of information that are relevant to data management using the
site
andhorizons
as abstract representations of soil profile data. Under conditions where the result has a particular unambiguous format, the results can be enhanced to make them easier to use by providing a full set of IDs from the parent SPC. This behavior offrameify
is only invoked when result ofFUN
isdata.frame
andidname
and/orhzidname
are present in the data.frame. This also has the constraint that result ID values are at least a subset of IDs from parent SPC. Internal management ofidname
andhzidname
byframeify
facilitates taking stock of potentially incomplete results. Merging back to the ID structure fills any gaps in the result withNA
, for unambiguous and complete ID sets that are safe to merge back into the parent object (e.g. usingsite<-
orhorizons<-
) or use in other downstream analysis.