Nizamuddin Siddiqui has Published 1958 Articles

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

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

5K+ 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 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

501 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

590 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

398 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

753 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

1K+ 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

660 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

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

611 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 create boxplot with horizontal lines on the minimum and maximum in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

1K+ 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

Advertisements