Nizamuddin Siddiqui has Published 2307 Articles

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

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 04-Sep-2020 06:54:36

593 Views

The default color of the bars created by using ggplot2 package is grey but we can change that color to any depending on our interest. This change is highly required in professions such as academic writing and analytics because everyone wants to look at attractive images. They are not meant ... Read More

How to save a plot as SVG created with ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 29-Aug-2020 08:05:31

3K+ Views

   There are multiple ways to save a plot created in R. Base R provides, metafile, bitmap, and postscript options to copy and save the plots created in R but we can also save the plots created with ggplot2 as an SVG file with the help of svglite package. The ... Read More

Why do we get warning 'newdata' had 1 row but variables found have X rows while predicting a linear model in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 29-Aug-2020 08:01:43

2K+ Views

The reason we get newdata had 1 row warning is the newdata is not correctly defined. We should give the name of the explanatory variable or independent variable to the newdata so that the model can identify that we are passing the mean of the explanatory variable, otherwise it considers ... Read More

How to increase the space between bars of a bar plot using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 29-Aug-2020 08:00:20

550 Views

When a bar plot is created then the distance or space between bars is equal but sometimes the width of the bar is large, therefore, it becomes a little difficult to understand the difference between those bars especially in cases when the data values are not very much different from ... Read More

How to replace space in a string value for some elements in a column of an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 29-Aug-2020 07:42:50

351 Views

Most of the times, the string data is in bad shape and we need to make it appropriate so that we can easily proceed with the analysis. There is also a situation in which a string column has some values where an extra space is used which was not required, ... Read More

How to change the column names in R within aggregate function?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 29-Aug-2020 07:36:13

368 Views

The column names in an R data frame are an important part of the data because by reading the column names any viewer is likely to understand the theoretical background behind it. If that name is not appropriate then we might want to change it. While using the aggregate function ... Read More

How to find the row and column number for the minimum and maximum values in an R matrix?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 28-Aug-2020 13:12:38

276 Views

A matrix can have one or more than one minimum and maximum values. Also, the size of the matrix can be just one column and multiple rows or thousands of columns and thousands of rows. The row number and column number for the minimum and maximum values in a matrix ... Read More

How to find pairwise maximum among multiple vectors in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 28-Aug-2020 12:25:54

531 Views

The pairwise maximum refer to the values that are largest between the vectors. For example, if we have a vector that contains 1, 2, 3 and a second vector contains 2, 1, 4 then the pairwise maximum will be 2, 2, 4 because the maximum between 1 and 2 is ... Read More

How to repeat a simulation to a fixed number of times in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 13:10:14

878 Views

Often, we simulate random values from different distributions in R. The base R provides some inbuilt functions for the same and if we want to repeat the simulation a fixed number of times then we write these inbuilt functions again and again. But we can do multiple simulations using a ... Read More

How to create a column in an R data frame with cumulative sum?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 24-Aug-2020 13:08:58

459 Views

The cumulative sum is used to determine the total sum of a variable or group and helps us to understand the changes in the values of that variable or group over time. While creating the cumulative, we must be sure that the total sum and the cumulative sum of the ... Read More

Advertisements