我理解为了在数据框中找到符合特定条件的行(即过滤数据),我会使用类似的代码:
s[(s$age < 20 | s$age > 40)]
但是,我是否会尝试找到具有“年龄”值+或 - 1与标准差的平均值的异常行?
s <- data.frame(
sample = c("s_1", "s_2", "s_3", "s_4", "s_5", "s_6", "s_7", "s_8"),
flavor = c("original", "chicken", "original", "original", "cheese", "chicken", "cheese", "original"),
age = c(23, 25, 11, 5, 6, 44, 50, 2),
scale = c( 4, 3, 2, 5, 4, 3, 1, 5))