• Skip to secondary menu
  • Skip to main content
  • Skip to primary sidebar

Python and R Tips

Learn Data Science with Python and R

  • Home
  • Python
  • Pandas
    • Pandas 101
  • tidyverse
    • tidyverse 101
  • R
  • Linux
  • Conferences
  • Python Books
  • About
    • Privacy Policy
You are here: Home / R / ggplot2 / Why can’t ggplot2 use %>% instead of “+”?

Why can’t ggplot2 use %>% instead of “+”?

January 30, 2018 by cmdlinetips

Have you ever mixed up dplyr’s pipe operator or magittr %>% with ggplot’s “+” while piping dplyr commands with ggplot2, you are not alone. Depending on where you misused “%>%” for “+”, you might get confusing errors like

  • Error: Mapping must be created by `aes()` or `aes_()`
  • Error in as.vector(x, “character”) : cannot coerce type ‘environment’ to vector of type ‘character’

Well. that is about to change, Hadley Wickham has been working on meaningful errors for tidyverse, like “Did you use %>% instead of +?”

Still, if you wonder, why can’t I use %>% in ggplot2 instead of “+”?. Hadley Wickham has commented on RStudio community.

Thanks to a question on https://t.co/fkYCCcgnXm from @dataandme, I did a little write up on why ggplot2 should use the pipe, but unfortunately never will: https://t.co/BD8xpg3f6j #rstats

— Hadley Wickham (@hadleywickham) January 29, 2018

Here is the short answer from Hadley Wickham,

Should ggplot2 use the pipe? IMO, yes.
Could ggplot2 support both the pipe and plus? No
Would it be worth it to create a ggplot3 that uses the pipe? No.

Check out the complete answer at
https://community.rstudio.com/t/why-cant-ggplot2-use/4372

If you still want to use %>%, try this package https://github.com/zeehio/ggpipe

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X

Related posts:

Default ThumbnailMost Useful R Packages for Data Science Boxplot with jittered Data Points in RHow to Make Boxplot in R with ggplot2? How to annotate with ellipses in ggplot2 using ggforce?Getting started with ggforce – a ggplot2 extension package Default Thumbnailggplot2 Version 3.0.0 Brings Tidy Evaluation to ggplot

Filed Under: ggplot2, R Tips, rstat, rstats Tagged With: ggplot2, R Tips, rstats

Primary Sidebar

Subscribe to Python and R Tips and Learn Data Science

Learn Pandas in Python and Tidyverse in R

Tags

Altair Basic NumPy Book Review Data Science Data Science Books Data Science Resources Data Science Roundup Data Visualization Dimensionality Reduction Dropbox Dropbox Free Space Dropbox Tips Emacs Emacs Tips ggplot2 Linux Commands Linux Tips Mac Os X Tips Maximum Likelihood Estimation in R MLE in R NumPy Pandas Pandas 101 Pandas Dataframe Pandas Data Frame pandas groupby() Pandas select columns Pandas select_dtypes Python Python 3 Python Boxplot Python Tips R rstats R Tips Seaborn Seaborn Boxplot Seaborn Catplot Shell Scripting Sparse Matrix in Python tidy evaluation tidyverse tidyverse 101 Vim Vim Tips

RSS RSS

  • How to convert row names to a column in Pandas
  • How to resize an image with PyTorch
  • Fashion-MNIST data from PyTorch
  • Pandas case_when() with multiple examples
  • An Introduction to Statistical Learning: with Applications in Python Is Here
  • 10 Tips to customize ggplot2 title text
  • 8 Plot types with Matplotlib in Python
  • PCA on S&P 500 Stock Return Data
  • Linear Regression with Matrix Decomposition Methods
  • Numpy’s random choice() function

Copyright © 2025 · Lifestyle Pro on Genesis Framework · WordPress · Log in

Go to mobile version