Hello, Sorry I am a noob. Hopefully I produced a decent reprex. Trying to reorder the facets in this dataset. I reproduced the problematic code as prescribed by the author of this package as listed on his website, but I am getting an error. . If you can please assist.
Thank you!
p.s. any suggestions on how to produce better questions/ topics/ reprex is also appreciated.
Thank you! Thank you!
k2_xrf<-tibble::tribble(
~Location, ~depth, ~units, ~param, ~count, ~units, ~age, ~units_age,
"Kiani", 0L, "cm", "Si", 2984L, "ppm", 3000L, "BP",
"Kiani", 2L, "cm", "Si", 3318L, "ppm", NA, NA,
"Kiani", 4L, "cm", "Si", 3296L, "ppm", NA, "BP",
"Kiani", 6L, "cm", "Si", 3712L, "ppm", 5400L, "BP",
"Kiani", 8L, "cm", "Si", 4416L, "ppm", NA, "BP",
"Kiani", 0L, "cm", "S", 3172L, "ppm", 3000L, "BP",
"Kiani", 2L, "cm", "S", 3411L, "ppm", NA, "BP",
"Kiani", 4L, "cm", "S", 3835L, "ppm", NA, "BP",
"Kiani", 6L, "cm", "S", 4281L, "ppm", 5400L, "BP",
"Kiani", 8L, "cm", "S", 3896L, "ppm", NA, "BP",
"Kiani", 0L, "cm", "K", 325L, "ppm", 3000L, "BP",
"Kiani", 2L, "cm", "K", 99L, "ppm", NA, "BP",
"Kiani", 4L, "cm", "K", 180L, "ppm", NA, "BP",
"Kiani", 6L, "cm", "K", 559L, "ppm", 5400L, "BP",
"Kiani", 8L, "cm", "K", 504L, "ppm", NA, "BP"
)
#This correctly produces the plot
library(tidyverse)
library(tidypaleo)
theme_set(theme_bw(8))
k2_xrf <- ggplot(k2_xrf, aes(x = count, y = depth)) +
geom_lineh() +
scale_y_reverse() +
facet_geochem_gridh(vars(param)) +
labs(x = "Count (ppm)" , y = "Depth (mm)")
k2_xrf
#Trying to reorder the facets with the code prescribed the author
k2_xrf %>%
mutate(param = fct_relevel(param, "Si", "S", "K")) %>%
ggplot(aes(x = value, y = depth)) +
geom_lineh() +
scale_y_reverse() +
facet_geochem_gridh(vars(param)) +
labs(x = "Count (ppm)" , y = "Depth (mm)")
k2_xrf
#Returns following error:
#**Error in UseMethod("mutate_") : no applicable method for 'mutate_' applied to an object of class "c('gg', 'ggplot')"**