You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.
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.
The text was updated successfully, but these errors were encountered:
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 freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The text was updated successfully, but these errors were encountered: