Could someone tell me how to average two histograms with R?
I came across the HistogramTools package and the AddHistograms function:
h1<-hist(na.omit(a[,1]),breaks = 100,plot=F) h2<-hist(na.omit(a[,2]),breaks = 100,plot=F) > AddHistograms(h1,h2) Error in .AddManyHistograms(x, main = main) : Histograms must have identical breakpoints for this operation. but I always have the same error Histograms must have identical breakpoints for this operation? can someone explain why? I am guessing is that a[,1] and a[,2] are not the same length, same with the outputs of h1 and h2 (i.e. I don't have the same length for "breaks","mids","counts" between h1 and h2).
Could you tell me how to average my two histograms using this function or anything else with R?
hist(c(a[,1],a[,2])), but without a reproducible example it's hard to tell. You should also specify what you intend by "average two histograms".VectorOfBreakpoints <- c(0, ..., ..)to each histogram, likebreaks = VectorOfBreakpoints?