ED2: Allow negative numbers in custom ED2IN tag vectors#2361
Merged
tonygardella merged 3 commits intoPecanProject:developfrom Jun 3, 2019
Merged
ED2: Allow negative numbers in custom ED2IN tag vectors#2361tonygardella merged 3 commits intoPecanProject:developfrom
tonygardella merged 3 commits intoPecanProject:developfrom
Conversation
This is particularly relevant to soil depth (SLZ).
ashiklom
commented
May 24, 2019
| are_numeric <- !is.na(try_numeric) | ||
| custom_tags[are_numeric] <- lapply(custom_tags[are_numeric], as.numeric) | ||
| custom_tags <- lapply(custom_tags, | ||
| tryCatch(as.numeric(x), warning = function(e) x)) |
Member
Author
There was a problem hiding this comment.
The tryCatch(...) is a more elegant version of what I had on the left. Using lapply instead of vapply makes this robust to custom_tags that are vectors.
ashiklom
commented
May 24, 2019
| "([[:space:]]*,[[:space:]]*[[:digit:]]+.?[[:digit:]]*)+") | ||
| # Works for decimals, negatives, and arbitrary spacing: "1.3,2.6, -7.8 , 8.1" | ||
| numvec_rxp <- paste0("^ *-?[[:digit:]]+.?[[:digit:]]*", | ||
| "([[:space:]]*,[[:space:]]*-?[[:digit:]]+.?[[:digit:]]*)+") |
Member
Author
There was a problem hiding this comment.
-? is regular expression syntax for "optional -".
serbinsh
approved these changes
May 30, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Allows
<ed2in_tags>that are negative vectors to work. This is particularly relevant to soil depth (SLZ). For example:Tagging @istfer and @serbinsh because you both work with ED.