Open moodymudskipper opened 4 years ago
dplyr
diamonds %>%
filter(cut != "Fair") %>%
group_by(cut) %>%
summarize(
AvgPrice = mean(price),
MedianPrice = as.numeric(median(price)),
Count = n()
) %>%
arrange(desc(Count))
data.table
diamondsDT <- data.table(diamonds)
diamondsDT[
cut != "Fair",
.(AvgPrice = mean(price),
MedianPrice = as.numeric(median(price)),
Count = .N
),
by = cut
][
order(-Count)
]
or
diamonds %>%
data.table() %>%
.[cut != "Fair",
.(AvgPrice = mean(price),
MedianPrice = as.numeric(median(price)),
Count = .N
),
by = cut
] %>%
.[order(-Count)]
tb
diamondsDT %tb>% .[
cut != "Fair",
AvgPrice = mean(price),
MedianPrice = as.numeric(median(price)), Count = .N,
by = cut]$
.[order(-Count),]
https://twitter.com/hrbrmstr/status/1265296181174943745
Here we'd just do: