我的数据集包含500个观测值。这是数据结构的任何示例:
df <- data.frame(rating_mean=c(3.6,4.0,3.7,4.8,3.9,5.1,4.1,4.3 ),actual_truth=c("true","false","true","true"))
对于“真”刺激,我想返回60个等级,其rating_mean最接近3.5的值,而对于“假”刺激,我要返回相同的项(总共120个)。到目前为止,我有这个,但它不正确:
df50 <- df %>% group_by(actual_truth) %>% top_n(n = 60,wt = rating_mean - 3.5)
谢谢。