Histograms

Histograms are the representation of the distribution of data(numerical or categorical). It is similar to a bar chart but it groups data in terms of ranges. 

R




# break is used for number of bins.
data(lynx)
 
# lynx is a built-in dataset.
lynx    
 
# hist function is used to plot histogram.
hist(lynx)
hist(lynx, col="green",
     main="Histogram of Annual Canadian Lynx Trappings")


Output :

Time Series:
Start = 1821
End = 1934
Frequency = 1
[1] 269 321 585 871 1475 2821 3928 5943 4950 2577 523 98 184
[14] 279 409 2285 2685 3409 1824 409 151 45 68 213 546 1033
[27] 2129 2536 957 361 377 225 360 731 1638 2725 2871 2119 684
[40] 299 236 245 552 1623 3311 6721 4254 687 255 473 358 784
[53] 1594 1676 2251 1426 756 299 201 229 469 736 2042 2811 4431
[66] 2511 389 73 39 49 59 188 377 1292 4031 3495 587 105
[79] 153 387 758 1307 3465 6991 6313 3794 1836 345 382 808 1388
[92] 2713 3800 3091 2985 3790 674 81 80 108 229 399 1132 2432
[105] 3574 2935 1537 529 485 662 1000 1590 2657 3396

R – Statistics

Plot The Distribution

R




data(lynx)
 
# if freq=FALSE this will draw normal distribution
hist(lynx)
hist(lynx,col="green",
     freq=FALSE ,main="Histogram of Annual Canadian Lynx Trappings")
 
curve(dnorm(x, mean=mean(lynx),
            sd=sd(lynx)), col="red",
      lwd=2, add=TRUE)


Output:

R – Statistics

R – Statistics

Statistics is a form of mathematical analysis that concerns the collection, organization, analysis, interpretation, and presentation of data. Statistical analysis helps to make the best use of the vast data available and improves the efficiency of solutions.

Similar Reads

R – Statistics

R Programming Language is used for environment statistical computing and graphics. The following is an introduction to basic R Statistics concepts like normal distribution (bell curve), central tendency (the mean, median, and mode), variability (25%, 50%, 75% quartiles), variance, standard deviation, modality, and skewness....

Data Concepts

Data can be formed in different structures and different formats, before starting the concepts of R Statistics we need to know the data formats....

Statistics in R

Average, Variance and Standard Deviation in R Mean, Median and Mode in R Programming Probability in R Discrete distributions Benford Distribution Bernoulli Binomial Hypergeometric distribution Geometric distribution Multinomial Negative binomial distribution Poisson distribution Zipf’s law Continuous distributions Beta distributions Dirichlet distributions Cauchy Chi-Square distribution Exponential Fisher-Snedecor Gamma Levy Log-normal distribution Normal and related distributions Pareto Distributions Student’s t distribution Uniform distribution Weibull Calculate Conditional Probability Binomial Distribution  Normal Distribution in R Beta Distribution in R Hypothesis in R Types of Hypothesis Null Hypothesis Alternative Hypothesis  One Sample T-Testing Two Sample T-Testing Paired Sample T-test Decision Errors in R  Type I Error Type II Error Confidence Intervals Correlation and Covariance Covariance Matrix Pearson Correlation Normal Probability Plot Quantile Quantile plots Residuals Leverage Plot Spearman’s Rank Correlation Measure Kendall Rank Correlation Measure Evaluation Metrics – Accuracy, Precision, Recall, F1-Score, MAE, MSE Root-Mean-Square Error ROC and AUC curve...

Plotting graphs in Statistics in R Programming Language

Following is a list of functions that are required to plot graphs for the representation of R Statistics data:...

Bar charts

A Bar chart represents categorical data with rectangular bars where the bars can be plotted vertically or horizontally....

Pie charts

...

Histograms

...

Box Plots

...

Contact Us