在列R中查找最小非零值 [英] Find minimum non-zero value in a column R

查看:98
本文介绍了在列R中查找最小非零值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在R中遇到这种情况:

I have this situation in R:

my_minimum <- min(my_data_frame[,my_column_number])

这将返回最小值.我想要的是最小非零值. 我见过很多更复杂的情况,人们想要一个非零最小值的向量,但我只想要一个数字,即存在于其中的最低非零值

This returns the minimum value. What I want is the minimum non-zero value. I have seen a lot of more complicated situations where people want a vector of the non-zero minimum values but I simply want a single number, the lowest non-zero value that exists in

my_column_number

my_data_frame

对于上下文,这是在for循环内发生的,该循环为每列迭代绘制一些内容,我需要获取非零最小值以添加到绘图中.

For context, this is taking place within a for loop that iteratively plots some stuff for each column, and I need to get the non-zero minimum to add to the plot.

推荐答案

应该可以解决问题.

 min(my_data_frame[my_data_frame$my_column_number>0,my_column_number])

这篇关于在列R中查找最小非零值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆