Statbump Error Message when using geom_bump in ggplot in R

Viewed 199

I am trying to make a bumpchart as depicted here: https://cran.r-project.org/web/packages/ggbump/readme/README.html

My data look exactly like the country/year/rank data used in the Tutorial section of that site, but for some reason I get this message for each line of my data (i.e. I have 12 observations, see below, and I get this same error message repeated 12 times):

1: In f(...) : 'StatBump' needs at least two observations per group

Here's what my data look like:

> bumpdata
       vars      mod_name rank
 1:     AWC Log_Reg_NVEAI    4
 2:     AWC     SVM_NVEAI    2
 3:     AWC      RF_NVEAI    4
 4:    clay Log_Reg_NVEAI    1
 5:    clay     SVM_NVEAI    1
 6:    clay      RF_NVEAI    1
 7: FloodPl Log_Reg_NVEAI    3
 8: FloodPl     SVM_NVEAI    4
 9: FloodPl      RF_NVEAI    3
10:  Precip Log_Reg_NVEAI    2
11:  Precip     SVM_NVEAI    3
12:  Precip      RF_NVEAI    2

I'm using this to make the plot (although I'm pretty sure this isn't the problem because I can get the correct plot if I import the country/year/rank data from the tutorial):

ggplot(bumpdata, aes(mod_name, rank, color = vars)) + geom_bump(size=2)

1 Answers

It appears that the geom_bump and StatBump stuff requires your X-axis varible to be numeric and continuous, you can't use bins like I was trying to do. (Or, you can rename your bins as numbers and convert your axis labels back when you're done).

Related