Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dplyr top_n() - Suppress status message?

Tags:

r

dplyr

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.

like image 920
Randy Minder Avatar asked Jan 20 '26 11:01

Randy Minder


1 Answers

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.

Compare

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
like image 164
MrFlick Avatar answered Jan 22 '26 01:01

MrFlick