How to Perform Univariate Analysis in R

Perform Univariate Analysis in R, In statistics, there are three different types of strategies for univariate data analysis. There are three types of analysis: univariate, bivariate, and multivariate.

The term “univariate analysis” refers to a single-variable analysis. Because the prefix “uni” indicates “one,” you’ll remember this.

Univariate analysis is a fundamental statistical data analysis technique. The data comprises only one variable and does not have to deal with a cause-and-effect relationship.

How to perform ANCOVA in R » Quick Guide »

Univariate analysis on a single variable can be done in three ways:

1. Summary statistics -Determines the value’s center and spread.

2. Frequency table -This shows how frequently various values occur.

3. Charts -A visual representation of the distribution of values.

Perform Univariate Analysis in R

Let’s create a variable and perform univariate analysis in r

data<- c(10, 5, 8, 7.5, 8, 45, 40, 51, 5, 16.5, 27, 7.8, 8, 10, 15)

1. Summary Statistics

To calculate various summary statistics for our data variable, we can use the following syntax.

Chi Square for Independence-Mantel–Haenszel test in R »

Let’s start with the mean of the variable,

[1] 17.58667

Now we can find out the median of the data

[1] 10

Range of the variable

[1] 51
[1] 5
max(data) - min(data)
[1] 46

We can now compute the interquartile range (spread of middle 50 percent of values)

[1] 13.85

Standard deviation is important for the continuous data variables,

[1] 15.51952

2. Frequency Table

The term “frequency” refers to how frequently something occurs. The number of times an event occurs is indicated by the observation frequency.

Wilcoxon Signed Rank Test in R » an Overview »

The frequency distribution table may include numeric or quantitative data that are category or qualitative. The distribution provides a glimpse of the data and allows you to identify trends.

To create a frequency table for our variable, we can use the following syntax:

   5  7.5  7.8    8   10   15 16.5   27   40   45   51
   2    1    1    3    2    1    1    1    1    1    1

We can infer the output like,

The value 5 occurs 2 times

The value 7.5 occurs 1 time

The value 8 occurs 3 time

And so on.

rbind in r-Combine Vectors, Matrix or Data Frames by Rows »

3. Charts

The following syntax can be used to create a boxplot:

A boxplot is a graph that displays a dataset’s five-number summary.

The following are the five numbers that make up the five-number summary:

The bare minimum.

The top quartile.

The average value.

The third quartile of the population.

The highest possible value.

Correlation Analysis in R? » Karl Pearson correlation coefficient »


The following syntax can be used to create a histogram:

A histogram is a sort of graphic that displays frequencies using vertical bars. A helpful technique to show the distribution of values in a dataset is to use this type of graphic.


The following syntax can be used to create a density curve.

How to Calculate Mahalanobis Distance in R »

The distribution of values in a dataset is represented by a density curve, which is a curve on a graph.

It’s especially useful for viewing a distribution’s “shape,” such as whether the distribution contains one or more “peaks” of often occurring values and if the distribution is skewed to the left or right.


Each of these graphs provides a different perspective on the distribution of values for our variable.

pipe operator in R-Simplify Your Code with %>% »


In the realm of statistics, univariate analysis is the most basic type of data analysis. The important thing to understand about univariate analysis is that there is only one data set involved.

While the univariate analysis is simple to do and understand, it can sometimes provide deceptive results, especially when there are multiple factors to consider.

In this situation, you should go on to bivariate and multivariate analysis, which will allow you to better analyze the data.

Random Forest Model in R » Prediction model »

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

eight − 7 =