Nizamuddin Siddiqui has Published 1958 Articles

How to display mean inside boxplot created by using boxplot function in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 14:30:54

784 Views

A boxplot shows the median as a measure of center along with other values but we might want to compare the means as well. Therefore, showing mean with a point is likely to be preferred if we want to compare many boxplots. This can be done by using points(mean(“Vector_name”)), if ... Read More

How to find the quantiles in R without quantile name?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 14:15:28

1K+ Views

The calculation of quantiles in R is very simple, we just need to use quantile function and it returns all the quantiles that are 0%, 25%, 50%, 75% and 100%. If we want to avoid the printing the name of these quantiles then we can use names=FALSE with the quantile ... Read More

How to create a matrix with random values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 14:11:16

8K+ Views

Generally, a matrix is created with given values but if we want to create the matrix with random values then we will use the usual method with the matrix function. Random selection in R can be done in many ways depending on our objective, for example, if we want to ... Read More

How to combine matrices having same number of columns in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 13:56:09

350 Views

The matrices that have same number of columns can be combined by rows. For example, if we have five matrices list, each having six columns then those matrices can be converted into a single matric by joining the rows of those matrices. It can be done by using do.call(rbind, ”List_of_matrices_object_name”).ExampleConsider ... Read More

How to create random sample based on group columns of a data.table in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 13:38:21

1K+ Views

Random sampling helps us to reduce the biasedness in the analysis. If we have data in groups then we might want to find a random sample based on groups. For example, if we have a data frame with a group variable and each group contains ten values then we might ... Read More

How to subset unique values from a list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 13:29:48

521 Views

We know that a list in R can have multiple elements of different data types but they can be the same as well. Whether we have the same type of elements or different ones, we might want to subset the list with unique values, especially in situations where we believe ... Read More

How to use shapiro wilk test to check normality of an R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 13:26:26

777 Views

To apply shapiro wilk test for normality on vectors, we just simply name the vector inside shapiro.test function but if we want to do the same for an R data frame column then the column will have to specify the column in a proper way. For example, if the data ... Read More

How to find power of a matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 13:23:12

881 Views

The power of a matrix in R cannot be found directly because there is not function in base R for that. Therefore, for this purpose we can use %^% of expm package. Firstly, we will install the expm package then load it and use %^%. For example, suppose we have ... Read More

How to increase the size of points on a scatterplot if the points are drawn based on another sequence using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 13:04:56

641 Views

When we draw a scatterplot using ggplot2 with points based on a sequence of values then the size of the points might be very small for the small values. As a result, it becomes a little difficult to view the points. Therefore, we might want to increase the size of ... Read More

How to extract elements of a list that do not contain NULL in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Sep-2020 13:01:20

1K+ Views

A list sometimes contains NULL elements along with other elements. Therefore, we might want to get rid of that NULL element so that we can use our list without any hustle. To do this, we can use lapply function with the following syntax −Syntax“List_name”[!unlist(lapply(“List_name”, is.null))]ExampleConsider the below list − Live Demox1Read More

Advertisements