ggslackr: Post a ggplot to a Slack channel

Description Usage Arguments Value Note Examples

View source: R/gg_slackr.R

Description

Unlike the dev_slackr function, this one takes a ggplot object, eliminating the need to have a graphics device (think use in scripts).

Usage

1
2
3
4
ggslackr(plot = last_plot(), channels = Sys.getenv("SLACK_CHANNEL"),
  scale = 1, width = par("din")[1], height = par("din")[2],
  units = c("in", "cm", "mm"), dpi = 300, limitsize = TRUE,
  api_token = Sys.getenv("SLACK_API_TOKEN"), file = "ggplot", ...)

Arguments

plot

ggplot object to save, defaults to last plot displayed

channels

list of channels to post image to

scale

scaling factor

width

width (defaults to the width of current plotting window)

height

height (defaults to the height of current plotting window)

units

units for width and height when either one is explicitly specified (in, cm, or mm)

dpi

dpi to use for raster graphics

limitsize

when TRUE (the default), ggsave will not save images larger than 50x50 inches, to prevent the common error of specifying dimensions in pixels.

api_token

the Slack full API token (chr)

file

prefix for filenames (defaults to ggplot)

...

other arguments passed to graphics device

Value

httr response object (invisibly)

Note

You need to setup a full API token (i.e. not a webhook & not OAuth) for this to work Also, uou can pass in as_user=TRUE as part of the ... parameters and the Slack API will post the message as your logged-in user account (this will override anything set in username)

Examples

1
2
3
4
5
## Not run: 
slackr_setup()
ggslackr(qplot(mpg, wt, data=mtcars))

## End(Not run)

hrbrmstr/slackr documentation built on May 18, 2018, 4:19 p.m.