Skip to content
This repository was archived by the owner on Aug 4, 2020. It is now read-only.
This repository was 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

Description

@pan-chu

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions