Nizamuddin Siddiqui has Published 2307 Articles

How to change the starting and ending points of axes labels using plot function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 13:07:17

657 Views

When we create a plot using plot function, the axes labels are automatically created based on the values of the variables that is being plotted. It is possible to set a limit to the labels for both the axes, X-axis and Y-axis and we can do this by using xlim ... Read More

How to create a rank variable using mutate function of dplyr package in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 13:05:29

432 Views

A rank variable is created to convert a numerical variable into ordinal variable. This is useful for non-parametric analysis because if the distribution of the numerical variable is not normal or there are assumptions of parametric analysis that cannot be followed by the numerical variable then the raw variable values ... Read More

How to extract first two characters from a string in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 13:04:35

1K+ Views

A string can be short or long, also we can have a vector or list of strings as well in R. Extraction of partial string is common when we want to use the strings for single or multiple comparisons. If we want to extract first two characters from a string, ... Read More

How to create boxplot with horizontal lines on the minimum and maximum in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 13:01:22

988 Views

A boxplot shows the minimum, first quartile, median, third quartile, and maximum. When we create a boxplot with ggplot2 it shows the boxplot without horizontal lines on the minimum and maximum, if we want to create the horizontal lines we can use stat_boxplot(geom= 'errorbar') with ggplot function of ggplot2.ExampleConsider the ... Read More

How to create a scatterplot with colors of the group of points in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 12:56:05

570 Views

A scatterplot is the plot that has one dependent variable plotted on Y-axis and one independent variable plotted on X-axis. Sometimes the pair of dependent and independent variable are grouped with some characteristics, thus, we might want to create the scatterplot with different colors of the group based on characteristics. ... Read More

How to reverse the bars of a bar plot a using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 12:54:00

826 Views

The bars of a bar plot are generally vertical from bottom to top but we can reverse them as well. Although, this is not a normal practice but we can do it if we want to. For this purpose, we will have to reverse the values on the Y-axis, as ... Read More

How to extract data from a plot created by ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 12:50:57

2K+ Views

Of course, a plot is created with some data but we might want to get the data from plot as well. This is possible in R with ggplot_build function but it works only for ggplot objects, if we create a plot with plot function then we cannot extract the data ... Read More

How to perform mathematical operations on elements of a list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 12:36:04

717 Views

A list can contain many elements and each of them can be of different type but if they are numerical then we can perform some mathematical operations on them such as addition, multiplication, subtraction, division, etc. To do this, we can use Reduce function by mentioning the mathematical operation and ... Read More

How to write the plot title in multiple lines using plot function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 12:34:17

2K+ Views

Mostly, the main title of a plot is short but we might have a long line to write for the main title of the plot. For example, a short version might be “Scatterplot” and a longer version might be “Scatterplot between X and Y”. Therefore, in plot function of R ... Read More

How to fill the missing values of an R data frame from the mean of columns?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 12:32:26

241 Views

Dealing with missing values is one of the initial steps in data analysis and it is also most difficult because we don’t fill the missing values with the appropriate method then the result of the whole analysis might become meaningless. Therefore, we must be very careful about dealing with missing ... Read More

Advertisements