# Thread: plotting 10 class intervals of frequency distribution.

1. ## plotting 10 class intervals of frequency distribution.

I am newbie to R, so I don't know exactly how to plot frequency distribution having 10 class intervals and calculate the proportion of under IQ of 120 using the frequency distribution above. In spite of I have searched many websites and tutorials I could not find out the solution.
Plz let me know, Thank you all.
This is continuous data.
119 87 89 131 122 106 121 100 95 121
119 89 128 123 84 99 119 105 117 92
96 85 112 99 90 96 123 102 81 129
108 109 84 134 130 105 113 103 126 92
127 97 108 94 122 123 122 82 97 132
110 89 92 109 131 95 121 94 112 90
122 95 87 114 130 123 84 109 116 106
96 109 110 128 102 102 101 113 100 108
88 109 133 81 107 122 100 100 102 109
101 109 118 105 118 127 87 119 90 131

2. You can use the hist function to plot frequency distribution.
I am not quite sure what you mean by 10 class intervals. The code below shows how to use the hist function with 10 bars. The code then calculates the proportion with IQ < 120, and displays the result on the chart.

Code:
``````IQ<-scan()
119 87 89 131 122 106 121 100 95 121
119 89 128 123 84 99 119 105 117 92
96 85 112 99 90 96 123 102 81 129
108 109 84 134 130 105 113 103 126 92
127 97 108 94 122 123 122 82 97 132
110 89 92 109 131 95 121 94 112 90
122 95 87 114 130 123 84 109 116 106
96 109 110 128 102 102 101 113 100 108
88 109 133 81 107 122 100 100 102 109
101 109 118 105 118 127 87 119 90 131

#plot frequency distribution
intervals<-10
h<-hist(IQ, breaks=seq(min(IQ), max(IQ), length=intervals+1))

#calculate proportion of class with than IQ<120
proportion <- length(IQ[IQ<120])/length(IQ)

# show proportion with IQ<120 on plot
abline(v=120, lty="dashed", col="red")
text(x=120, y=0.95*max(h\$counts), paste("Proportion < 120 =", proportion), pos=2)``````
To get the proportion directly from the chart you could have IQ intervals of 10 and the sum the counts for each interval below 120 and divide it by the total number of IQ results, as in the code below
Code:
``````h2<-hist(IQ, breaks=seq(80,140,by=10))
text(x=h2\$mids, y=h2\$counts, labels=h2\$counts, pos=1)
# proportion with IQ<120
a<-sum(h2\$counts[h2\$breaks<120])
b<-sum(h2\$counts)
proportion2<-a/b
abline(v=120, lty="dashed", col="red")
text(x=120, y=0.95*max(h2\$counts), labels=paste("Proportion < 120 =\n(", paste(h2\$counts[h2\$breaks<120], collapse="+"),")/",length(IQ),"=",proportion2), pos=4, cex=0.8)``````

 Tweet

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts