Hi there, the example you were looking at applies some javascript code (the full code is viewable in the codepen embedded in that documentation page: http://codepen.io/plotly/pen/WvWLWJ)
However, we did recently add dropdown menus to Plotly so you’re able to add dropdowns simply in R (without having to implement js as in that example!)
This feature is currently in our dev package, not our latest CRAN package (this is what you are using), but we will be updating our CRAN package in the near future!
In the meantime, you can follow this blog post: http://moderndata.plot.ly/new-feature-dropdown-menus-in-plotly-and-r/ and use our latest dev version of Plotly for R: https://github.com/ropensci/plotly