Learn R Programming

slackr (version 2.0.1)

register_onexit: Append text_slackr as on.exit to functions.

Description

Appends to the body of a function an on.exit call to run at the end of the call.

Usage

register_onexit(
  f,
  ...,
  header_msg = NULL,
  use_device = FALSE,
  env = parent.frame(2),
  channel = Sys.getenv("SLACK_CHANNEL"),
  username = Sys.getenv("SLACK_USERNAME"),
  icon_emoji = Sys.getenv("SLACK_ICON_EMOJI"),
  bot_user_oauth_token = Sys.getenv("SLACK_BOT_USER_OAUTH_TOKEN")
)

Arguments

f

function or character

...

expressions to be sent to Slack

header_msg

boolean, message to append to start of Slack output, Default: NULL

use_device

boolean, passes current image in the graphics device to Slack as part of f, Default: FALSE

env

environment to assign appended function to with relation to the function environment, Default: parent.frame(2) (global environment)

channel

which channel to post the message to (chr)

username

what user should the bot be named as (chr)

icon_emoji

what emoji to use (chr) "" will mean use the default

bot_user_oauth_token

Slack bot user OAuth token

Value

function

Details

If a character is passed to f then it will evaluate internally to a function.

See Also

text_slackr

Examples

Run this code
# NOT RUN {
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
weight <- c(ctl, trt)

#pass a message to Slack channel 'general'
register_onexit(lm,'bazinga!',channel="#general")

lm.D9 <- slack_lm(weight ~ group)

#test that output keeps inheritance
summary(lm.D9)

#pass a message to Slack channel 'general' with a header message to begin output
register_onexit(lm,'bazinga!',
channel="#general",
header_msg='This is a message to begin')

lm.D9 <- slack_lm(weight ~ group)

#onexit with an expression that calls lm.plot
register_onexit(lm,{
 par(mfrow = c(2, 2), oma = c(0, 0, 2, 0))
 plot(z)
},
channel="#general",
header_msg = 'This is a plot just for this output',
use_device = TRUE)

lm.D9 <- slack_lm(weight ~ group)

#clean up slack channel from examples
delete_slackr(count = 6,channel = '#general')
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab