r - How to find the amount of positive numbers -
i new in world of r, , have rather easy questions, troubles me.
i have load of numbers:
abc=rnorm(100, mean=0, sd=1) i want find out how many of these numbers positive. tried:
length(which(abc>0) but didn't work. suggestions?
what want is:
sum(abc > 0) try abc > 0 first. give boolean vector true abc values positive, length of both abc , boolean vector identical. since true equal 1 , false equal 0, sum of elements of vector give desired count. common trick in r, why felt answer in case.
another useful trick doing same mean, e.g. mean(abc > 0) give proportion of values in abc positive.
your original approach work (provided correct bracketing), taste which() not function intended such use.
Comments
Post a Comment