search for: light_duty

Displaying 6 results from an estimated 6 matches for "light_duty".

2017 Nov 09
4
weighted average grouped by variables
...00, 1508238000), class = c("POSIXct", "POSIXt"), tzone = ""), direction = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L), .Label = c("A", "B"), class = "factor"), type = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L), .Label = c("car", "light_duty", "heavy_duty", "motorcycle"), class = "factor"), avg_speed = c(41.1029082774049, 40.3333333333333, 40.3157894736842, 36.0869565217391, 33.4065155807365, 37.6222222222222, 35.5), n_vehicles = c(447L, 24L, 19L, 23L, 706L, 45L, 26L)), .Names = c("date_time&q...
2017 Nov 11
0
weighted average grouped by variables
...gt; you could use split/ lapply approach, however it is probably not much better than dplyr method. > > sapply(split(mydf, mydf$type), function(speed, n_vehicles) sum(mydf$speed*mydf$n_vehicles)/sum(mydf$n_vehicles)) > gives you averages > The result of this calculation is: car light_duty heavy_duty motorcycle 36.54109 36.54109 36.54109 36.54109 But this doesn't give the same result as the dplyr method which is: date_time type vel <dttm> <fctr> <dbl> 1 2017-10-17 13:00:00 car 36.39029 2 2017-10-17...
2017 Nov 09
1
weighted average grouped by variables
...238000), class = c("POSIXct", "POSIXt"), tzone = ""), > direction = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L), .Label = c("A", "B"), class = "factor"), > type = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L), .Label = c("car", "light_duty", "heavy_duty", "motorcycle"), class = "factor"), > avg_speed = c(41.1029082774049, 40.3333333333333, 40.3157894736842, 36.0869565217391, 33.4065155807365, 37.6222222222222, 35.5), > n_vehicles = c(447L, 24L, 19L, 23L, 706L, 45L, 26L)), > .Names = c(&quot...
2017 Nov 09
2
weighted average grouped by variables
...0), class = > c("POSIXct", "POSIXt"), tzone = ""), direction = structure(c(1L, 1L, 1L, 1L, 2L, 2L, > 2L), .Label = c("A", "B"), class = "factor"), type = structure(c(1L, 2L, 3L, 4L, 1L, > 2L, 3L), .Label = c("car", "light_duty", "heavy_duty", "motorcycle"), class = > "factor"), avg_speed = c(41.1029082774049, 40.3333333333333, > 40.3157894736842, 36.0869565217391, 33.4065155807365, > 37.6222222222222, 35.5), n_vehicles = c(447L, 24L, 19L, 23L, 706L, 45L, 26L)), > .Names = c(...
2017 Nov 09
0
weighted average grouped by variables
...00, 1508238000), class = c("POSIXct", "POSIXt"), tzone = ""), direction = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L), .Label = c("A", "B"), class = "factor"), type = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L), .Label = c("car", "light_duty", "heavy_duty", "motorcycle"), class = "factor"), avg_speed = c(41.1029082774049, 40.3333333333333, 40.3157894736842, 36.0869565217391, 33.4065155807365, 37.6222222222222, 35.5), n_vehicles = c(447L, 24L, 19L, 23L, 706L, 45L, 26L)), .Names = c("date_time&q...
2017 Nov 09
1
weighted average grouped by variables
...= > c("POSIXct", "POSIXt"), tzone = ""), > direction = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L), .Label = c("A", "B"), > class = "factor"), > type = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L), .Label = c("car", > "light_duty", "heavy_duty", "motorcycle"), class = "factor"), > avg_speed = c(41.1029082774049, 40.3333333333333, 40.3157894736842, > 36.0869565217391, 33.4065155807365, 37.6222222222222, 35.5), > n_vehicles = c(447L, 24L, 19L, 23L, 706L, 45L, 26L)), > .Names = c(...