July 4, 2018

Dataset

Quarterly earnings per Johnson & Johnson share

library(dplyr); library(datasets)
data("JohnsonJohnson")
jjShares<-as.data.frame(JohnsonJohnson) %>% rename(Price=x) %>% 
    mutate(Time=time(JohnsonJohnson)) 
head(jjShares)
  Price    Time
1  0.71 1960.00
2  0.63 1960.25
3  0.85 1960.50
4  0.44 1960.75
5  0.61 1961.00
6  0.69 1961.25

Johnson & Johnson share price

library(plotly)
plot_ly(jjShares, x=~Time, y=~Price,
        text = ~paste("Time: ", Time, '<br>Price:', Price, '$')) %>%
    add_lines()

The End

Thanks!