Create a function to change bin size in a histogram with hist in R -
write function accepts vector, vector of integers, main axis label , x axis label. function should iterate on each element in vector of integers , produce histogram each integer value, setting bin count element in input vector, , labeling main , x-axis specified parameters. should label y-axis read frequency, bins = , number of bins.
i trying not reading in nclass 3 different bin sizes correctly. doing wrong?
plot.historgrams <- function(x,nclass, ...){ (i in 1:length(nclass)) { hist(x,nclass=nclass[i], ...) } } plot.histograms(hidalgo.dat[,1], c(12,36,60), main="1872 hidalgo issue",xlab= "thickness (mm)")
it seems working when use breaks , put x= in front of data set.
plot.historgrams <- function(x,b, ...){ (i in 1:length(b)){ hist(x=x,breaks=b[i], ylab=paste("frequency, bins= ",b[i]), ...) } } plot.historgrams(x=hidalgo.dat[,1], c(12,36,60), main="1872 hidalgo issue",xlab= "thickness (mm)")
Comments
Post a Comment