Nizamuddin Siddiqui has Published 2307 Articles

How to change the bars color to grey shade of a bar graph created by using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Sep-2020 06:00:14

1K+ Views

When we create a bar graph using ggplot2, the color of the bars is dark grey but it can be changed to different colors or we can also give different shades of grey to them. This will be helpful if we are plotting a pattern of categorical data. For example, ... Read More

How to show all X-axis labels in a bar graph created by using barplot function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 07-Sep-2020 05:51:30

451 Views

In base R, the barplot function easily creates a barplot but if the number of bars is large or we can say that if the categories we have for X-axis are large then some of the X-axis labels are not shown in the plot. Therefore, if we want them in ... Read More

How to generate a sequence of a date in each month for a fixed number of months using R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 13:27:07

732 Views

Every month have common dates except few such as February do not have 30 or 31 and even 29 in some years and there are months that contain 30 days while some contains 31 days. Therefore, finding a date say the first date, a middle date, or a last date ... Read More

How to match two string vectors if the strings case is different in both the vectors in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 13:06:16

108 Views

We know that, R is a case sensitive programming language, hence matching strings of different case is not simple. For example, if a vector contains tutorialspoint and the other contains TUTORIALSPOINT then to check whether the strings match or not, we cannot use match function directly. To do this, we ... Read More

Why the t.test returns a smallest p-value of 2.2e – 16 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 12:37:03

2K+ Views

When we perform a t test in R and the difference between two groups is very large then the p-value of the test is printed as 2.2e – 16 which is a printing behaviour of R for hypothesis testing procedures. The actual p-value can be extracted by using the t ... Read More

How to concatenate column values and create a new column in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 12:34:39

795 Views

Sometimes we want to combine column values of two columns to create a new column. This is mostly used when we have a unique column that maybe combined with a numerical or any other type of column. Also, we can do this by separating the column values that is going ... Read More

How to draw gridlines in a graph with abline function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 12:21:34

143 Views

Gridlines are the horizontal and vertical dotted lines, and they help to organize the chart so that the values on the labels becomes better readable to viewers. This is helpful specially in situations where we plot a large number of data points. A graph drawn by plot function can have ... Read More

How to select rows based on range of values of a column in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 12:19:29

2K+ Views

Extraction or selection of data can be done in many ways such as based on an individual value, range of values, etc. This is mostly required when we want to either compare the subsets of the data set or use the subset for analysis. The selection of rows based on ... Read More

How to change the color and size of the axes labels of a plot created by using plot function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 12:16:41

258 Views

The default size of axes labels created by using plot function does not seem to be large enough and also it does not look appealing. Therefore, we might want to change their size and color because the appearance of a plot matters a lot. This can be done by setting ... Read More

How to add a new column to an R data frame with largest value in each row?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 12:14:10

600 Views

When we have a data frame that contains all numerical columns then we might want to find the largest value in each row. For example, if we have a sales data set in which each row represents a customer and columns represent the products with quantities of values as values ... Read More

Advertisements