data <- data.frame(Names = c("Alie", "Kathy", "Corie", "Suzie", "Nathan", "Ryan", "Jake"),
Earnings = c(0, 200, 1000, 890, 200, 0, 0))
library(dplyr)
data <- data %>% slice_min(Earnings, n = 1)
I got the following output:
Names Earnings
Alie 0
Ryan 0
Jake 0
Based on minimum earnings, I want R to select one row at random
There should be a similar output
Names Earnings
Ryan 0
or
Names Earnings
Jake 0
Is sample() the right command to use?
data <- data %>% slice_min(Earnings, n = 1)
data <- sample(data, 1)
Please feel free to give me advice