geom_spidergram (new) - #53
Conversation
Merge branch 'main' into geom-spidergram # Conflicts: # R/ASTR_geom_spider.R # R/ASTR_normalise_wrapper.R # man/geom_spider.Rd # man/normalise_data.Rd
|
I was not able to fix the "discrete values to continuous scale" problem other than the solution you suggested. I have no idea why this occurs. We create the The only difference I see is how the graphical elements are created; the coordinate transformation might be the issue. There are two differences in your approach compared to others:
And for whatever reason, the geom doesn't find the |
| normalise_geochem(df, reference = reference, ...) | ||
| }, | ||
| hundred = { | ||
| numeric_cols <- names(df)[sapply(df, is.numeric)] |
There was a problem hiding this comment.
This test should be moved to the normalisation function so that this function does not fail if it is called outside of the wrapper function.
| df[numeric_cols] <- normalise_rows(df[numeric_cols]) | ||
| df | ||
| }, | ||
| element = { |
There was a problem hiding this comment.
Please create a separate function for this normalisation. The wrapper is a convenience function and should not do anything else than dispatching it to functions that do the actual work.
| df[numeric_cols] <- lapply(df[numeric_cols], function(x) x / divisor) | ||
| df | ||
| }, | ||
| sample = { |
There was a problem hiding this comment.
Please create a separate function for this normalisation which is them called here. The wrapper is a convenience function and should not do anything else than dispatching it to functions that do the actual work.
| unknown = { | ||
| stop( | ||
| "Unknown reference '", reference, "'. ", | ||
| "`reference` must be one of: ", | ||
| "a geochemical reference composition (see `references_geochem`), ", | ||
| "a column name in `df`, ", | ||
| "an ID value in `df`, ", | ||
| "or '100%'." | ||
| ) | ||
| } |
There was a problem hiding this comment.
| unknown = { | |
| stop( | |
| "Unknown reference '", reference, "'. ", | |
| "`reference` must be one of: ", | |
| "a geochemical reference composition (see `references_geochem`), ", | |
| "a column name in `df`, ", | |
| "an ID value in `df`, ", | |
| "or '100%'." | |
| ) | |
| } | |
| stop( | |
| "Unknown reference '", reference, "'. ", | |
| "`reference` must be one of: ", | |
| "a geochemical reference composition (see `references_geochem`), ", | |
| "a column name in `df`, ", | |
| "an ID value in `df`, ", | |
| "or '100%'." | |
| ) |
The default function of switch statement is unnamed. It is automatically called in the input value does not match any other options.
|
New approach to geom_spidergram(), allowing to supply a character vector of elements as aesthetic.
Previous code for data treatment is copied at the end of the file.