# hist{graphics}

6 messages
Open this post in threaded view
|

## hist{graphics}

 # Can someone help with this simple frequency histogram problem (n = 15)? # I use four class limits: [90,95], [95,100], [100,105], [105,110]. # These coincide with the limits obtain by pretty {base}. # Proper frequencies would be: (1,5,6,3). # But hist{graphics} gives me a histogram showing frequencies (1,8,3,3), # with or without argument break = ... # Replicable codes below. Thanks. set.seed(123) x<-rnorm(15,mean=100,sd=5); x<-as.integer(x) x<-sort(x) x breaks<-seq(90,110,by=5); breaks pretty(x,n=5) # pretty {base} x.cut<-cut(x,breaks,right=F) ; x.cut freq<-table(x.cut); cbind(freq) hist(x,breaks=breaks) # hist {graphics} hist(x) ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: hist{graphics}

 Never mind. Thanks. I found that adding parameter right=F to the call fixes it. On 2019/7/12 下午 05:10, Steven wrote: > # Can someone help with this simple frequency histogram problem (n = 15)? > # I use four class limits: [90,95], [95,100], [100,105], [105,110]. > # These coincide with the limits obtain by pretty {base}. > # Proper frequencies would be: (1,5,6,3). > # But hist{graphics} gives me a histogram showing frequencies (1,8,3,3), > # with or without argument break = ... > # Replicable codes below. Thanks. > > set.seed(123) > x<-rnorm(15,mean=100,sd=5); x<-as.integer(x) > x<-sort(x) > x > breaks<-seq(90,110,by=5); breaks > pretty(x,n=5) # pretty {base} > x.cut<-cut(x,breaks,right=F) ; x.cut > freq<-table(x.cut); cbind(freq) > hist(x,breaks=breaks) # hist {graphics} > hist(x) > > > ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: hist{graphics}

 On 12/07/2019 11:38 a.m., Steven wrote: > Never mind. Thanks. > > I found that adding parameter right=F to the call fixes it. Drawing a histogram of discrete data often leads to bad results. Histograms are intended for continuous data, where no observations fall on bin boundaries. You often get a more faithful representation of discrete data using something like plot(table(x)) Duncan Murdoch > > On 2019/7/12 下午 05:10, Steven wrote: >> # Can someone help with this simple frequency histogram problem (n = 15)? >> # I use four class limits: [90,95], [95,100], [100,105], [105,110]. >> # These coincide with the limits obtain by pretty {base}. >> # Proper frequencies would be: (1,5,6,3). >> # But hist{graphics} gives me a histogram showing frequencies (1,8,3,3), >> # with or without argument break = ... >> # Replicable codes below. Thanks. >> >> set.seed(123) >> x<-rnorm(15,mean=100,sd=5); x<-as.integer(x) >> x<-sort(x) >> x >> breaks<-seq(90,110,by=5); breaks >> pretty(x,n=5) # pretty {base} >> x.cut<-cut(x,breaks,right=F) ; x.cut >> freq<-table(x.cut); cbind(freq) >> hist(x,breaks=breaks) # hist {graphics} >> hist(x) >> >> >> > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|