by educationdata · 7y ago · 0 comments
dplyr syntax is definitely more concise and readable than base R, but comparing to data.table I don't think it has any advantage in terms of saving time writing or reading code.
https://stackoverflow.com/questions/21435339/data-table-vs-d...
I feel like the first example is far more readable than the second. People can disagree on this, but the adoption rates of dplyr versus data.table do suggest (don't prove, but suggest) that the consensus on the issue leans towards dplyr. As we've noted, people certainly aren't adopting dplyr for the speed.
diamondsDT[cut != "Fair", .(AvgPrice = mean(price),
MedianPrice = as.numeric(median(price)),
Count = .N), cut][order(-Count)]
There is no need to break it to 10 lines.