How to create a histogram for uniform data in R?

R ProgrammingServer Side ProgrammingProgramming

<p>To create a histogram for uniform data in R, we can simply use hist function but the bars size may vary even if the frequency is same. Therefore, for this purpose, we need to define the breaks as shown in the below example.</p><h2>Example</h2><p>To create a histogram for uniform data in R, use the code given below &minus;</p><pre class="demo-code notranslate language-rscript" data-lang="rscript">hist(1:6)</pre><h2>Output</h2><p>If you execute the above given code, it generates the following output &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/59145/histogram.jpg" class="fr-fic fr-dib" width="553" height="552"></p><p>To create a histogram for uniform data in R, use the code given below &minus;</p><pre class="demo-code notranslate language-rscript" data-lang="rscript">hist(1:8) </pre><h2>Output</h2><p>If you execute the above given code, it generates the following output &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/59145/histogram1.jpg" class="fr-fic fr-dib" width="553" height="552"></p><p>To create a histogram for uniform data in R, use the code given below &minus;</p><pre class="demo-code notranslate language-rscript" data-lang="rscript">hist(1:6,breaks=0:6)</pre><h2>Output</h2><p>If you execute the above given code, it generates the following output &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/59145/histogram2.jpg" class="fr-fic fr-dib" width="553" height="552"></p>
raja
Updated on 09-Nov-2021 07:08:51

Advertisements