如何排除R中设置的最不同值?
我的DF看起来像这样,但更大:
values <- c(22,16,23,15,14.5,19)
groups <- rep(c("a","b"), each = 3)
df <- data.frame(groups, values)
我的每组具有1-3个值(在组A组的3值和B组B值3值中)。我现在想从每个组中排除最不同的价值。 在此示例中,我想排除16和b 19。
谢谢您的帮助!
I have a df looking like this but larger:
values <- c(22,16,23,15,14.5,19)
groups <- rep(c("a","b"), each = 3)
df <- data.frame(groups, values)
I have between 1-3 values per group (in the example 3 values for group a and 3 values for group b). I now want to exclude the most dissimilar value from each group.
In this example I would want to exclude a 16 and b 19.
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在寻找一个丢弃的价值,则可以删除距平均值最高距离的观察值:
If you're looking for one value to discard, you can remove the observation that has the highest distance from the mean value per group: