Week 6: Presentations

Robert W. Walker

Overview

  1. AMA
  2. Interactive Graphics in R
    • Network data and interaction with networkD3.
    • Plotly and ggplotly
    • Crosstalk related tools
    • ggiraph
  3. Presentations with Quarto
    • reveal.js
    • Powerpoint [.pptx]
    • Beamer [\LaTeX]

The Assignments

  • Due today: Produce two interactive graphics for the portfolio.
  • Due next time: Produce a marketing presentation of yourself.

Syllabus Guidance

This Week

Next Week

AMA

If there are things you want to figure out with quarto, what are they?

  • I have one example on functions from the blog.

The plotly package

plotly as a package has far more it can do.

Code
library(plotly)
library(magrittr)
library(tidyquant)
INTC <- tq_get("INTC")
INTC <- tail(INTC, 90)
INTC$ID <- seq.int(nrow(INTC))
INTC %<>%
    mutate(close = round(close, digits = 2))

accumulate_by <- function(dat, var) {
    var <- lazyeval::f_eval(var, dat)
    lvls <- plotly:::getLevels(var)
    dats <- lapply(seq_along(lvls), function(x) {
        cbind(dat[var %in% lvls[seq(1, x)], ], frame = lvls[[x]])
    })
    dplyr::bind_rows(dats)
}

INTC <- INTC %>%
    accumulate_by(~ID)
fig <- INTC %>%
    plot_ly(x = ~ID, y = ~close, frame = ~frame, type = "scatter", mode = "lines",
        fill = "tozeroy", fillcolor = "rgba(73, 26, 201, 0.5)", line = list(color = "rgb(73, 26, 201)"),
        text = ~paste("Date: ", date, "<br>Close: $", close), hoverinfo = "text")
fig <- fig %>%
    layout(title = "Intel Stock Closing Price: Last 90 Days", yaxis = list(title = "Close",
        range = c(0, 50), zeroline = F, tickprefix = "$"), xaxis = list(title = "Day",
        range = c(0, 90), zeroline = F, showgrid = F), margin = list(t = 120))
fig <- fig %>%
    animation_opts(frame = 100, transition = 0, redraw = FALSE)
fig <- fig %>%
    animation_slider(currentvalue = list(prefix = "Day "))
fig

The Crosstalk Idea

Image from book

Presentations in Quarto

Today’s yml

Screen shot of yaml

Formatting: New slides

  1. New slides are
    • #
    • ##
    • ---

Transitions can be set with incremental in yaml or…

Incrementals

Pauses

. . .

Multicolumn

Multicolumn

Snippets

!multic30 and then shift-tab

Code snippets

Formatting

Size and Scroll

Global

Themes

Themes

Comments

  • Green 1
  • Brown
  • Purple

Backgrounds [Sometimes themes are bad]

Background

Background

Just because

Customizing Images


![](image1.png){.absolute top=200 left=0 width="350" height="300"}

![](image2.png){.absolute top=50 right=50 width="450" height="250"}

![](image3.png){.absolute bottom=0 right=50 width="300" height="300"}

Animations

Animation

Shown

# Fill in the spot we created for a plot
output$phonePlot <- renderPlot({
  # Render a barplot
})

Shown

# Fill in the spot we created for a plot
output$phonePlot <- renderPlot({
  # Render a barplot
  barplot(WorldPhones[,input$region]*1000, 
          main=input$region,
          ylab="Number of Telephones",
          xlab="Year")
})

With text

Animation

With text

Implicit

Animation

This part is neat

Fragments

tabsets

Tabsets

tabsets don’t multiplex

Code
mtcars %>%
    ggplot() + aes(x = wt, y = disp, color = cyl) + geom_point() + theme_minimal()

Code
mtcars %>%
    ggplot() + aes(x = hp, y = disp, color = cyl) + geom_point() + theme_minimal()

Code
mtcars %>%
    ggplot() + aes(x = hp, y = mpg, color = cyl) + geom_point() + theme_minimal()

Powerpoint

I am not a fan but…

Industry powerpoint.

How To Do?

Page