# note the insertion of new rows with missing values
group2NA(mtcars, "vs", "cyl")
# need to group lines by city somehow!
plot_ly(txhousing, x = ~date, y = ~median) %>% add_lines()
# instead of using group_by(), you could use group2NA()
tx <- group2NA(txhousing, "city")
plot_ly(tx, x = ~date, y = ~median) %>% add_lines()
# add_lines() will ensure paths are sorted by x, but this is equivalent
tx <- group2NA(txhousing, "city", ordered = "date")
plot_ly(tx, x = ~date, y = ~median) %>% add_paths()
Run the code above in your browser using DataLab