Sgg | R Documentation |
The set Sgg
should be used like this: Sgg$geom_point()
.
It transforms on the fly an original {ggplot2} function supposed to be used
with the +
operator (like p + geom_point()
) into a pipeable version
(like p %>% Sgg$geom_point()
).
Sgg(ggplot, ...)
## S3 method for class 'subsettable_Sgg'
x$name
## S3 method for class 'subsettable_Sgg'
.DollarNames(x, pattern = "")
ggplot |
An object of class "ggplot" (or "theme"). |
... |
Further arguments passed to the the ggplot function (see Details). |
x |
The |
name |
The name of the ggplot function to make pipeable. |
pattern |
A regular expression to list matching names. |
The function returned by Sgg$fun
is a modified version of the
function fun
where a first argument ggplot =
is added, and the
instruction ggplot + ...
is added in its body. A message
is also added in the body to explicitly warn about these changes. All the
other arguments of fun
remain valid and should keep their original meaning.
The changes are done on the fly, and the original function fun
is not
altered anywhere else (and in particular, no alteration is done in a package
or a namespace). When using this construct, make sure that: (1) you
understand what is done, (2) you are aware that you use an altered version of
the original function, (3) a bug or strange behavior may occur due to the
patch and the original author of the function is not responsible in this case
(the problem must be reported to the author of Sgg
and the maintainer of
the present package instead), and (4) the patched function exhibits an
additional argument and behaves differently to what is described in the help
page of the original, non-patched, function!
The Sgg()
function just returns an error message. When subsetted
with the name of a {ggplot2} function (e.g., Sgg$geom_point()
), it
returns a modified version of that function in such a way that it can be
used with a pipe operator.
library(ggplot2)
data(iris)
ggplot(aes(x = Petal.Length, y = Sepal.Length, col = Species) , data = iris) |>
Sgg$geom_point() |>
Sgg$labs(x = "Sepal length (mm)", y = "Petal length (mm)")
# Also try completion with Sgg$<tab>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.