Skip to content

geom_spidergram (new) - #53

Draft
archaeothommy wants to merge 18 commits into
mainfrom
geom-spidergram
Draft

geom_spidergram (new)#53
archaeothommy wants to merge 18 commits into
mainfrom
geom-spidergram

Conversation

@archaeothommy

@archaeothommy archaeothommy commented Jul 3, 2026

Copy link
Copy Markdown
Owner

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.

@archaeothommy

Copy link
Copy Markdown
Owner Author

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 x aesthetic in setup data and it is a discrete aesthetic from the onset... I don't understand why ggplot2 thinks this is a continuous variable and never had this problem in the other geoms.

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:

  • e.g. this case study relies on the functions of existing geoms.
  • My other geoms plot from data object, rather than coord, without transformation.

And for whatever reason, the geom doesn't find the elements_data and other pre-compiled objects...

Comment thread R/ASTR_normalise_wrapper.R Outdated
normalise_geochem(df, reference = reference, ...)
},
hundred = {
numeric_cols <- names(df)[sapply(df, is.numeric)]

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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.

Comment thread R/ASTR_normalise_wrapper.R Outdated
df[numeric_cols] <- normalise_rows(df[numeric_cols])
df
},
element = {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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.

Comment thread R/ASTR_normalise_wrapper.R Outdated
df[numeric_cols] <- lapply(df[numeric_cols], function(x) x / divisor)
df
},
sample = {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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.

Comment thread R/ASTR_normalise_wrapper.R Outdated
Comment on lines +109 to +118
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%'."
)
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Suggested change
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.

@archaeothommy

Copy link
Copy Markdown
Owner Author
  • normalise_element: should state that the ratio between the element and the reference element is calculated
  • normalise_sample: check if provided is ID is unique as part of tests, not further down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants