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
within
my_data_frame
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.
Select a blank cell (H1) for placing the minimum value, enter formula =SMALL(A1:E7,COUNTIF($A$1:$E$7,0)+1) into the Formula Bar, and then press the Enter key. Then the minimum value of specified range excluding zero is populated in the selected cell as above screenshot shown.
Minimum value of a column in R can be calculated by using min() function. min() Function takes column name as argument and calculates the Minimum value of that column.
In R, we can find the minimum or maximum value of a vector or data frame. We use the min() and max() function to find minimum and maximum value respectively. The min() function returns the minimum value of a vector or data frame. The max() function returns the maximum value of a vector or data frame.
To find the minimum value of a column, use the MIN() aggregate function; it takes the name of the column or expression to find the minimum value. In our example, the subquery returns the minimum value in the temperature column (subquery: SELECT MIN(temperature) FROM weather ).
If you use a vector:
min(myvector[myvector > 0])
That should do the trick.
min(my_data_frame[my_data_frame$my_column_number>0,my_column_number])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With