Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Explain the use of aes() for mapping variables to aesthetics - (Eric's instructor checkout contribution) #93

Open
pan-chu opened this issue Sep 8, 2018 · 0 comments

Comments

@pan-chu
Copy link

pan-chu commented Sep 8, 2018

A very common mistake I have seen people make with ggplot2 is the use of aes() for mapping certain variables in the data frame to some graphical feature, or rather, forgetting to use it.

For example, if you'd like set the size of your data points according to their corresponding values (e.g. data points are genes and you'd like the sizes to reflect the corresponding expression level for each gene), you could do something like this: geom_point(aes(size = expression_level)). Using the aes() argument allows you to "map" the variable - "expression_level" to the size aesthetic, giving each data point a different size, accordingly.

I've seen many people miss the aes(), so they'd do something like this: geom_point(size = expression_level) and really struggle to figure out why the graph isn't being rendered the way they wanted.

On the other hand, one could use geom_point(size = 5) to apply a size uniformly to all data points in the graph.

It may be good to explicitly describe this common pitfall so that learners are aware of the difference between using and not using the aes() function and can choose appropriately.

@pan-chu pan-chu changed the title Explain the use of aes() for mapping variables to aesthetics - (Eric's instructor contribution) Explain the use of aes() for mapping variables to aesthetics - (Eric's instructor checkout contribution) Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant