# NOT RUN {
## generate data to make/save plot (as a .png file)
x <- rnorm(300)
y <- x + rnorm(300, 0, .75)
col <- c(rep("#002244aa", 50), rep("#440000aa", 50))
bg <- c(rep("#6699ffaa", 50), rep("#dd6666aa", 50))
## crate temporary file name
tmp <- tempfile(fileext = ".png")
## save as png
png(tmp, 6, 6, "in", res = 127.5)
par(tcl = -.15, family = "Inconsolata",
font.main = 2, bty = "n", xaxt = "l", yaxt = "l",
bg = "#f0f0f0", mar = c(3, 3, 2, 1.5))
plot(x, y, xlab = NULL, ylab = NULL, pch = 21, cex = 1,
bg = bg, col = col,
main = "This image was uploaded by rtweet")
grid(8, lwd = .15, lty = 2, col = "#00000088")
dev.off()
## post tweet with media attachment
post_tweet("a tweet with media attachment", media = tmp)
# example of replying within a thread
## first post
post_tweet(status="first in a thread")
## lookup status_id
my_timeline <- get_timeline(rtweet:::home_user())
## ID for reply
reply_id <- my_timeline$status_id[1]
## post reply
post_tweet("second in the thread",
in_reply_to_status_id = reply_id)
# }
Run the code above in your browser using DataLab