Jim Beam Jim Beam - 3 months ago 12
R Question

R: Summary information only for positive numbers in a range

I have variable in a dataframe that contains values between -70 and 78. If I use the

summary()
function, I get a summary with all the numbers included (as expected).
Is it possible to run
summary()
ONLY on the positive numbers (>0) within that variable?

Answer

Yes, it's possible.

The code below works, assuming your data frame is called myData and the column you want to filter (to values >0) is called x.

summary(myData[myData$x>0,])