r - how can i find the total frequency of a given range in a histogram? -
i created histogram simulation, , need find total number of instances x-variable greater given value. specifically, data correlation (ranging -1 1, bin size 0.05), , want find percent of events correlation greater 0.1. finding total number of events greater 0.1 fine, because it's easy percent compute.
library(psych) library(lessr) corrdata=null (i in 1:1000){ x1 <- rnorm(mean=0, sd = 1, n=20) x2 <- rnorm(mean=0, sd = 1, n=20) data <- data.frame(x1,x2) r <- with(data, cor(x1, x2)) corrdata <- append(corrdata,r) } describe(corrdata) hist <- hist(corrdata, breaks=seq(-1,1,by=.05), main="n=20") describe(hist) count(0.1, "n=20")
try this:
n=500 bh=hist(runif(n,-1,1)) #str(bh) sum(bh$counts[bh$mids>=.1])/n
Comments
Post a Comment