I have try to plot using the ggridges package. My code runs but the plot only shows white empty space. If I change the alpha values, I get
Picking joint bandwidth of NaN
Sample data
# Create the dataframe
sample <- data.frame(No = 0:4, nm = c(6217.276, 5087.43, 4512.67, 4990.639, 6504.022), nm1 = c(5922.943, 4700.321, 4194.645, 4496.32, 6140.53))
# Print the dataframe
sample
| No | nm | nm1 |
| 0 | 6217.276 | 5922.943 |
| 1 | 5087.43 | 4700.321 |
| 2 | 4512.67 | 4194.645 |
| 3 | 4990.639 | 4496.32 |
| 4 | 6504.022 | 6140.53 |
My code. I started by converting my data into long format:
sample_long <- pivot_longer(sample, cols = c(nm,nm1), names_to = "para")
sample_long %>%
mutate(NoFct = fct_rev(as.factor(No))) %>%
ggplot(aes(y = NoFct)) +
geom_density_ridges(
aes(x = value, fill= para),
alpha = .8
)