Nizamuddin Siddiqui has Published 2307 Articles

How to create side by side histograms in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 06:17:24

2K+ Views

To create side by side histograms in base R, we first need to create a histogram using hist function by defining a larger limit of X-axis with xlim argument. After that we can create another histogram that has the larger mean and smaller standard deviation so that the bars do ... Read More

How to identify duplicate values in a column of matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 06:15:50

352 Views

We can easily identify duplicate values in a matrix by using duplicated function but it does not specify that the first occurrence is also duplicated. Therefore, we need to use it with OR sign | and the argument fromLast = TRUE of duplicated function so that the first occurrence of ... Read More

How to compare two columns in an R data frame for an exact match?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 06:12:05

6K+ Views

Sometimes analysis requires the user to check if values in two columns of an R data frame are exactly the same or not, this is helpful to analyze very large data frames if we suspect the comparative values in two columns. This can be easily done with the help of ... Read More

How to create a scatterplot with regression line using ggplot2 with 0 intercept and slope equals to 1 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 06:08:44

230 Views

To create a regression line with 0 intercept and slope equals to 1 using ggplot2, we can use geom_abline function but we need to pass the appropriate limits for the x axis and y axis values. For example, if we have two columns x and y in a data frame ... Read More

How to convert a time series object to a vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 06:07:11

2K+ Views

To convert a time series object into a vector, we just need to read that object with as.numeric and store it in some other object or in the same object. For example if we have a time series object x then it can be converted to a vector by using ... Read More

How to convert multiple columns in an R data frame into a single numerical column along with a column having column names as factor?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 06:04:55

814 Views

When we receive data from any source, it is highly likely that it would not be a perfect data set for the intended analysis, therefore, we need to perform some cleaning or mining based on the characteristics of the data. For example, if we have a column name of a ... Read More

How to perform one-way anova with unequal sample sizes in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:59:43

901 Views

To perform the one-way anova with sample sizes having different sizes we can use aov function. Suppose we have a categorical column defined as Group with four categories and a continuous variable Response both stored in a data frame called df then the one-way anova can be performed as −aov(Response~Group, ... Read More

How to generate standard normal random numbers in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:54:52

3K+ Views

A standard normal distribution is the type of distribution that has mean equals to zero with standard deviation 1. If we want to generate standard normal random numbers then rnorm function of R can be used but need to pass the mean = 0 and standard deviation = 1 inside ... Read More

How to remove list elements by their name in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:53:06

1K+ Views

Data analysis not only includes mathematical operations, we have to spend a lot of time in data cleaning, data mining, feature engineering etc. One operation could be removing list elements by their name if they are not helpful to achieve our objective. The removal of the elements by using their ... Read More

How to create a line chart using ggplot2 with larger width in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Dec-2020 05:50:43

92 Views

The width of the line chart can be increased by using size argument inside geom_line aesthetics of ggplot2. For example, if we have a data frame df that contains two numerical columns x and y, and we want to create a line chart between the two with larger width then ... Read More

Advertisements