# NOT RUN {
# Sum over sensors ----
pedestrian %>%
summarise(Total = sum(Count))
# Sum over sensors by days ----
pedestrian %>%
index_by(Date) %>%
summarise(Total = sum(Count))
## .drop = TRUE ----
pedestrian %>%
summarise(Total = sum(Count), .drop = TRUE)
tourism %>%
group_by(Region, State) %>%
summarise(geo_trips = sum(Trips))
# example from tidyr
stocks <- tsibble(
time = as.Date('2009-01-01') + 0:9,
X = rnorm(10, 0, 1),
Y = rnorm(10, 0, 2),
Z = rnorm(10, 0, 4)
)
stocks %>% gather(stock, price, -time)
# example from tidyr
stocks <- tsibble(
time = as.Date('2009-01-01') + 0:9,
X = rnorm(10, 0, 1),
Y = rnorm(10, 0, 2),
Z = rnorm(10, 0, 4)
)
stocksm <- stocks %>% gather(stock, price, -time)
stocksm %>% spread(stock, price)
pedestrian %>%
nest(-Sensor)
pedestrian %>%
group_by(Sensor) %>%
nest()
nested_ped <- pedestrian %>%
nest(-Sensor)
nested_ped %>%
unnest(key = id(Sensor))
nested_tourism <- tourism %>%
nest(-Region, -State)
nested_tourism %>%
unnest(key = id(Region | State))
# }
Run the code above in your browser using DataLab