Randy Minder Randy Minder - 1 month ago 12
R Question

dplyr top_n() - Suppress status message?

I have some R code that looks as follows:

rawList <- df %>% select(colIndex) %>% top_n(rows)

This executes as I would expect, but when it runs, I get output that looks like this:

Selecting by ReadTime

I just recently added the top_n() code and never saw this message before adding this function. Now I'm starting to see it. I assume it's comming from the top_n() function, and I cannot find a way to suppress this message.


That message appears when you don't explicitly pass a wt parameter to top_n to tell it which column to use select the top values for.


dd <- data.frame(x = c(10, 4, 1, 6, 3, 1, 1)) 
dd %>% top_n(2)
# Selecting by x
dd %>% top_n(2, x) # use column name