Write a function that accepts a vector, a vector of integers, a main axis label and an x axis label. This function should iterate over each element in the vector of integers and produce a histogram for each integer value, setting the bin count to the element in the input vector, and labeling main and x-axis with the specified parameters. You should label the y-axis to read Frequency, bins = and the number of bins.
I am trying this but it is not reading in the nclass for the three different bin sizes correctly. What am I doing wrong?
plot.historgrams <- function(x,nclass, ...){
for (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 to be working when I use breaks and put an x= in front of the data set.
plot.historgrams <- function(x,b, ...){
for (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)")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.