Presuming you have the tidyverse
package installed and loaded, your code works fine for me.
To help identify the problem, can you please share a reprex (reproducible example)? This will ensure we're all looking at the same data and code. A guide for creating a reprex can be found here.