ga_model_tweet: Upload an interactive visualisation so it can be embedded in...

Description Usage Arguments Details See Also Examples

View source: R/models.R

Description

Inspired by https://datatitian.com/how-to-turn-your-ggplot2-visualization-into-an-interactive-tweet/ this uploads your model output into Google Cloud storage, in the right format to embed in a tweet

Usage

1
ga_model_tweet(model_output, twitter, title, bucket, image = "")

Arguments

model_output

A ga_model_result object created by ga_model

twitter

Your twitter handle e.g. @holomarked

title

Twitter preview card title text

bucket

The GCS bucket to upload to

image

An optional image to display before the visualition runs

Details

This should work with all model outputs that are using library(htmlwidgets)

If using plotly, you need an account to use plotly_IMAGE to generate the preview image.

If you don't use a preview image, a generic one will be supplied instead.

You need to authenticate with 'googleCloudStorageR' before running this function so it can upload the appropriate files and make them public.

https://cards-dev.twitter.com/validator is useful to test what it will look like on Twitter.

See Also

Other GA modelling functions: ga_model_edit(), ga_model_example(), ga_model_load(), ga_model_make(), ga_model_save(), ga_model_write(), ga_model()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
  library(googleAnalyticsModelR)
  library(googleAnalyticsR)
  library(plotly)

  # create your htmlwidget output - in this case plot.ly
  output <- ga_time_normalised(81416156, interactive_plot = TRUE)
  
  # if you have a plot.ly account, you can generate a static image
  plotly_IMAGE(output$plot, out_file = "tweet.png")

  # now upload - assumes auto-authentication with googleCloudStorage
  library(googleCloudStorageR)
  ga_model_tweet(output, 
                 "@HoloMarked", 
                 "Test2 ga_model twitter upload", 
                 bucket = "mark-edmondson-public-read",
                 image = "tweet.png")

## End(Not run)

MarkEdmondson1234/googleAnalyticsR_public documentation built on Aug. 30, 2020, 7:28 a.m.