Learn R Programming

slackr (version 2.0.1)

ggslackr: Post a ggplot to a Slack channel

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

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,
  bot_user_oauth_token = Sys.getenv("SLACK_BOT_USER_OAUTH_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.

bot_user_oauth_token

the Slack bot user OAuth token (chr)

file

prefix for filenames (defaults to ggplot)

...

other arguments passed to graphics device

Value

httr response object (invisibly)

Examples

Run this code
# NOT RUN {
slackr_setup()
ggslackr(qplot(mpg, wt, data=mtcars))
# }

Run the code above in your browser using DataLab