'Plotting three vectors (1 categorical, 2 numeric) in ggridges
I have a challenge similar to the one here: plotting two categorical vectors in ggridges except that my abundance data does not include whole numbers. Is there a way to plot species on the y-axis (categorical), elevation on the x-axis (integer), and display density as a function of abundance?
Here is some code for an example:
set.seed(1)
Data <- data.frame(
Abundance = sample(0.1:100),
Organism = sample(c("organism1", "organism2"), 100, replace = TRUE)
)
elev = rep(seq(from = 500, to = 4000), 100)
Data <- cbind(elev, Data)
When I try the tidyr::uncount() solution proposed in the above link:
Data_sum <- Data %>%
tidyr::uncount(Abundance)
I get the following error message:
Error in `tidyr::uncount()`:
! Can't convert from `weights` <double> to <integer> due to loss of precision.
Is there a work-around to use non-integer values of abundance?
Thanks in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
