Benjamin Burr
benjaminburr.bsky.social
Benjamin Burr
@benjaminburr.bsky.social
Statistician who loves dogs, running, reading, and statistics. 🇨🇦 in Sheffield 🇬🇧 living my best Yorkshire life. Account is mostly for lurking.
But add_count() from another comment seems to do the same with less typing, except it doesn’t change x to a factor.
October 1, 2025 at 9:41 AM
Okay, tested that in R. Maybe not what you wanted.

data[, x := factor(x)][, N := .N, by = .(x)][order(-N)]

might be closer. If you want unique values of the factor counted in a second column and to order those as well, it would go: by = .(x,y) and order(x,y,-N) as needed.
October 1, 2025 at 9:38 AM
I can’t be sure this will work the way you want without checking some things but I would do something like:

library(data.table)
setDT(data)
data[, .N, by = .(x)][order(N)]

Maybe order(-N) if you want the sorting reversed, and .(factor(x)) if default factor level order is fine and it behaves.
September 30, 2025 at 7:37 PM
I’m now selling this as an NFT. Starting price is $45 billion.
March 30, 2025 at 8:18 AM
I’ve been following many/all of the ones I’ve run across for a couple of months so you can probably start with my Following list. There should be a couple hundred on there.
January 23, 2025 at 4:52 PM
So excited! That’s good timing with our supposed “less busy” period. I won’t say anything about the date to my huge following, of course, but will check the website every few minutes in early January. Thank you! 😁
November 29, 2024 at 3:32 PM