Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

scale_type

Determine default scale type


Description

You will need to define a method for this method if you want to extend ggplot2 to handle new types of data. If you simply want to pass the vector through as an additional aesthetic, return "identity".

Usage

scale_type(x)

Arguments

x

A vector

Value

A character vector of scale types. These will be tried in turn to find a default scale. For example, if scale_type returns c("foo", "bar") and the vector is used with the colour aesthetic, ggplot2 will first look for scale_colour_foo then scale_colour_bar.

Examples

scale_type(1:5)
scale_type("test")
scale_type(Sys.Date())

ggplot2

Create Elegant Data Visualisations Using the Grammar of Graphics

v3.3.3
MIT + file LICENSE
Authors
Hadley Wickham [aut] (<https://orcid.org/0000-0003-4757-117X>), Winston Chang [aut] (<https://orcid.org/0000-0002-1576-2126>), Lionel Henry [aut], Thomas Lin Pedersen [aut, cre] (<https://orcid.org/0000-0002-5147-4711>), Kohske Takahashi [aut], Claus Wilke [aut] (<https://orcid.org/0000-0002-7470-9261>), Kara Woo [aut] (<https://orcid.org/0000-0002-5125-4188>), Hiroaki Yutani [aut] (<https://orcid.org/0000-0002-3385-7233>), Dewey Dunnington [aut] (<https://orcid.org/0000-0002-9415-4582>), RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.