Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(tidyverse)
- library(plotly)
- set.seed(2001)
- ## make 10 random data series
- data <- data.frame(
- t = rep(1:50, 10),
- id = sort(rep(1:10, 50)),
- y = rnorm(500)
- )
- ## cumulate the random variates by group
- data <- data %>%
- group_by(id) %>%
- mutate(y2 = cumsum(y))
- ## plot
- plot <- data %>%
- plot_ly(x = ~ t, y = ~y2, text = ~id) %>%
- add_lines(split = ~id, color = I('gray'), alpha = 0.5) %>%
- hide_legend()
- plot
Add Comment
Please, Sign In to add comment