Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 106 of 196

How to subset one or more sub-elements of a list in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 732 Views

A list contains different type of elements and each of the them can have varying elements. To subset these sub-elements we can use sapply function and use c to subset the number of corresponding sub-elements. For example, if we have a list that contains five elements and each of those elements have ten sub-elements then we can extract 1, 2, 3 etc elements from sub-elements.ExampleConsider the below list −x1

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 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 −x1

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 11-Mar-2026 651 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 those points. It can be done by using scale_size_continuous function in which we can set a range for the points size.ExampleConsider the below data frame −x

Read More

How to find power of a matrix in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 897 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 a matrix called M and we want to find the M raise to the power 2 then it can be done as − M %^%2ExampleInstalling and Loading expm package −install.packages("expm") library(expm)ExampleM1

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 793 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 frame name is df and the column name is x then the function will work as shapiro.test(df$x).Examplex1

Read More

How to subset unique values from a list in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 540 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 that the values must be same. To do this, we can use unique function.ExampleConsider the below list −x1

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 367 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 the below matrices and their list −M1

Read More

How to create a matrix with random values in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 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 randomly select values from normal distribution then rnorm function will be used and to store it in a matrix, we will pass it inside matrix function.ExampleM1

Read More

How to find the quantiles in R without quantile name?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 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 function. For example, if we have a vector called x then the quantiles without names can be found as quantile(x,names=FALSE).Examplex1

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 801 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 we are plotting the columns of an R data frame then we will reference them instead of vector name.ExampleConsider the below data and the boxplot −x

Read More
Showing 1051–1060 of 1,958 articles
« Prev 1 104 105 106 107 108 196 Next »
Advertisements