Error: unexpected symbol %>%

How about the leading quotemark?

See the FAQ: How to do a minimal reproducible example reprex for beginners.