I have a dataframe with positive and negative numbers. What I need to return is the smallest positive number. Is there a function that does this?
dfcount <- data.frame(A=c(1,2,3,4,-5,-6,-7))
ie minpositive(dfcount) returns 1 and not -7
Thank you for your help
This function would work:
minpositive = function(x) min(x[x > 0])
For example:
dfcount <- data.frame(A=c(1,2,3,4,-5,-6,-7))
minpositive(dfcount)
# 1
This should work:
min(dfcount$A[dfcount$A > 0])
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