Description Usage Arguments Details See Also Examples
This scale allow for easy labeling of data in weight measurements. The scale has two major arguments, 'base' and 'system'. 'system' determine the measurement system, currently "imperial" and "metric" is implemented. For 'base' please refer to details.
1 2 3 4 5 6 7 8 9 10 11  scale_x_mass(name = waiver(), breaks = waiver(),
minor_breaks = waiver(), labels = waiver(), limits = NULL,
expand = waiver(), oob = censor, na.value = NA_real_,
position = "bottom", sec.axis = waiver(), base = "gram",
system = "metric", ignore = NULL)
scale_y_mass(name = waiver(), breaks = waiver(),
minor_breaks = waiver(), labels = waiver(), limits = NULL,
expand = waiver(), oob = censor, na.value = NA_real_,
position = "left", sec.axis = waiver(), base = "gram",
system = "metric", ignore = NULL)

name 
The name of the scale. Used as the axis or legend title. If

breaks 
One of:

minor_breaks 
One of:

labels 
One of:

limits 
A numeric vector of length two providing limits of the scale.
Use 
expand 
Vector of range expansion constants used to add some
padding around the data, to ensure that they are placed some distance
away from the axes. Use the convenience function 
oob 
Function that handles limits outside of the scale limits
(out of bounds). The default replaces out of bounds values with 
na.value 
Missing values will be replaced with this value. 
position 
The position of the axis. "left" or "right" for vertical scales, "top" or "bottom" for horizontal scales 
sec.axis 
specify a secondary axis 
base 
Character, dertermine what the base unit is, defaults to "gram". 
system 
Character, dertermine what measurement system to use is, defaults to "metric". 
ignore 
Character, which units to ignore. 
For "metric", base must be one of
gigatonne
megatonne
tonne
kilogram
gram
milligram
microgram
nanogram
picogram
And for "imperial", base must be one of
ton
pound
Other position scales: scale_x_length
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  library(ggplot2)
set.seed(1)
df < data.frame(
x = 1:100,
y = cumsum(rnorm(100)) * 100
)
base < ggplot(df, aes(x, y)) +
geom_line()
# Will default to grams
base +
scale_y_mass()
# Different baseline unit can be set with `base` argument
base +
scale_y_mass(base = "kilogram")
# Imperial system also implemented
base +
scale_y_mass(base = "ton", system = "imperial")
# Transformation between systems can be done on the fly. First element
# of system denotes the system you are moving from, and the second element
# denotes the system you are moving to.
base +
scale_y_mass(base = "kilogram", system = c("metric", "imperial"))

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.