Nizamuddin Siddiqui has Published 2307 Articles

How to find the mean of row values in an R data frame using dplyr?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:51:50

1K+ Views

The mean of row values can be found by using rowwise function of dplyr package along with the mutate function to add the new column of means in the data frame. The rowwise function actually helps R to read the values in the data frame rowwise and then we can ... Read More

How to display central limit theorem using uniform random variable in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:48:55

128 Views

The central limit theorem says that as the sample size increases the distribution of the sample means approaches normal distribution. Therefore, irrespective of the actual population distribution if we take samples of larger size and find the mean of these samples then the distribution of these sample means will be ... Read More

How to find the residual of a glm model in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:46:44

1K+ Views

In a linear model, a residual is the difference between the observed value and the fitted value and it is not different for a general linear model. The difference between linear model and the general linear model is that we use a probability distribution to create a general linear model. ... Read More

How to add a column in an R data frame with consecutive numbers?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:45:10

6K+ Views

Addition of a column with consecutive might have different objectives such as getting the sequence of numbers, representing serial numbers, representing ids, identification of each row, or a variable. We can use the sequence starting from any number up to the number of rows if we know the number of ... Read More

How to find the cumulative sum but restarts it if a value is 1 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:42:36

686 Views

Sometimes we want to find the conditional cumulative sums and these conditions can be resetting the cumulative if a particular value occurs. For example, finding the cumulative sum of a variable frame but restarting the sum if 1 occurs. In R, we can do this with the help of with, ... Read More

How to find the group-wise correlation coefficient in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:40:16

801 Views

If we have two continuous and one categorical column in an R data frame then we can find the correlation coefficient between continuous values for the categories in the categorical column. For this purpose, we can use by function and pass the cor function with the spearman method as shown ... Read More

How to subset rows of an R data frame using grepl function?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:38:07

4K+ Views

The grepl function in R search for matches to argument pattern within each element of a character vector or column of an R data frame. If we want to subset rows of an R data frame using grepl then subsetting with single-square brackets and grepl can be used by accessing ... Read More

How to find the column means of a column based on another column values that represent factor in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:35:48

1K+ Views

If we have a column that represent factor then we might want to find the mean of values in other column(s) for the factor levels. This is helpful in comparing the levels of the factor. In R, we can find the mean for such type of data by using aggregate ... Read More

How to convert a string vector into an integer vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:34:25

971 Views

A string vector contains element inside double-quotes and an integer vector does not have any quotes. Sometimes integer values are stored in double-quotes hence the vector of these values is treated as a string vector in R but we need the integer values to perform mathematical operations. Therefore, we can ... Read More

How to find the mean of a square matrix elements by excluding diagonal elements in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:32:40

191 Views

There are many ways to find the mean of a matrix elements by excluding diagonal elements, this mean is actually the mean of lower triangular matrix and the upper triangular matrix. We can simply use mean function by creating a vector of lower and upper triangular matrix as shown in ... Read More

Advertisements