This post is about `ggplot2` and `dplyr` packages, so let’s start with loading them:

``````library(ggplot2)
library(dplyr)
``````

I can’t be the first person to make the following mistake:

``````ggplot(mtcars, aes(x = wt, y = mpg)) %>%
geom_point()
``````

Can you spot the mistake in the code above? Look closely at the end of the first line.

The operator should be the `+` used in `ggplot2` for layering, not the `%>%` operator used in `dplyr` for piping, like this:

``````ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point()
``````

So what happens if you accidentally use the pipe operator instead of the `+`? You get the following error:

``````Error in get(x, envir = this, inherits = inh)(this, ...) :
Mapping should be a list of unevaluated mappings created by aes or aes_string
``````

My Google search for this error did not yield my careless mistake as a potential cause. Since many people use these two packages together, I’m guessing such mix-up of operators can’t be too uncommon (right? I can’t be the only one…). So I’m leaving this post here for the next person who makes the same mistake.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8367796,"math_prob":0.88161093,"size":1035,"snap":"2022-27-2022-33","text_gpt3_token_len":266,"char_repetition_ratio":0.11057226,"word_repetition_ratio":0.033333335,"special_character_ratio":0.25120774,"punctuation_ratio":0.12264151,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97542953,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-06-30T22:08:15Z\",\"WARC-Record-ID\":\"<urn:uuid:5dfbbf87-2029-4dcf-8aca-d73a1ad8c6bd>\",\"Content-Length\":\"33913\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0d23b29a-9597-4454-8ad6-40e991a3a32e>\",\"WARC-Concurrent-To\":\"<urn:uuid:ea637144-4047-40ad-a0f5-d046cd2ba03f>\",\"WARC-IP-Address\":\"167.172.139.120\",\"WARC-Target-URI\":\"http://www.citizen-statistician.org/2015/09/til-what-happens-if-you-use-instead-of-in-ggplot2/\",\"WARC-Payload-Digest\":\"sha1:SC4UBBJJK4JHH2S7545RJ3WN72M44Q32\",\"WARC-Block-Digest\":\"sha1:GN76POSB2375YYZDBGXEOWBV5SKBP4V5\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103915196.47_warc_CC-MAIN-20220630213820-20220701003820-00079.warc.gz\"}"}