# How to Perform Univariate Analysis in R

**Methods – finnstats**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Recommended to read most recent job openings and UpToDate tutorials from finnstats

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,

mean(data) [1] 17.58667

Now we can find out the median of the data

median(data) [1] 10

Range of the variable

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

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

IQR(data) [1] 13.85

Standard deviation is important for the continuous data variables,

sd(data) [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:

table(data) data 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 »

boxplot(data)

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.

hist(data)

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.

plot(density(data))

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

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

## Conclusion

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 »

The post How to Perform Univariate Analysis in R appeared first on finnstats.

**leave a comment**for the author, please follow the link and comment on their blog:

**Methods – finnstats**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.