You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on mountaineering data with country, year, and Nclimbers. Because Nclimbers varies hugely by year and by country, I want to use Nclimbers rather than ranks.
I used your example, and it works well!
ggplot(df, aes(year, value, color = country)) +
geom_bump()
but with my data set I get errors
"1: In compute_group(...) : 'StatBump' needs at least two observations per group."
The problem seems to be that 5 countries (Argentina, Canada, France Russia, Switzerland) had no climbers two of the three years, and they are omitted from the plot. But I have a solution (below)
Hi David
I'm working on mountaineering data with country, year, and Nclimbers. Because Nclimbers varies hugely by year and by country, I want to use Nclimbers rather than ranks.
I used your example, and it works well!
ggplot(df, aes(year, value, color = country)) +
geom_bump()
but with my data set I get errors
"1: In compute_group(...) : 'StatBump' needs at least two observations per group."
The problem seems to be that 5 countries (Argentina, Canada, France Russia, Switzerland) had no climbers two of the three years, and they are omitted from the plot. But I have a solution (below)
Here are the data:
country <- c( "Argentina", "Canada", "China", "China", "France" , "India", "India", "India", "Italy",
"Italy", "Japan", "Japan", "Japan" , "Nepal", "Nepal" , "Russia", "S Korea", "S Korea", "Spain", "Spain", "Switzerland", "UK" , "UK" , "UK", "USA", "USA" , "USA")
year <- c(1, 3, 1, 3, 2, 1, 2, 3, 1,2, 1, 2, 3, 2, 3, 3, 2, 3, 1, 2, 1, 1, 2, 3, 1, 2, 3)
Nclimbers <- c(20, 305, 35, 805, 318, 55, 206, 993, 67, 164, 156, 444, 431, 177, 377, 319, 350,
374, 16, 350, 33, 40, 429, 1007, 27, 859, 1668)
rank <- c(8, 9, 5, 4, 6, 3, 7, 3, 2, 9, 1, 2, 5, 8, 6, 8, 4, 7, 9, 5 , 6, 4, 3, 2, 7, 1, 1)
climbers <- tibble(country, year, Nclimbers, rank)
A solution is to fill in the missing years with Nclimbers = 0
climberfill <- climbers %>% tidyr::complete(country, year, fill = list(Nclimbers = 0))
Now when I run ggplot, it works, and all countries are represented!
ggplot(climberfill, aes(year, Nclimbers, color = country)) + geom_bump()
Perhaps add an explanation to the guidelines about this warning and how to deal with it.
The text was updated successfully, but these errors were encountered: