Nizamuddin Siddiqui has Published 1958 Articles

What is the difference between na.omit and na.rm in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Feb-2021 08:14:36

2K+ Views

The na.omit performs any calculation by considering the NA values but do not include them in the calculation, on the other hand, na.rm remove the NA values and then perform any calculation. For example, if a vector has one NA and 5 values in total then their sum using na.omit ... Read More

How to perform Wilcoxon test for all columns in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Feb-2021 08:10:44

2K+ Views

Performing Wilcoxon test for all columns in an R data frame means that we want to use this test for single samples and the Wilcoxon test for single sample is used to test for the median of the sample, whether the median is equal to something or not. And if ... Read More

How to include a zero with tick in base R plot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Feb-2021 08:04:09

397 Views

When we create a plot in base R the Y-axis values are generated automatically and mostly zero is now shown except in few cases that can’t be defined in particular but happens when there exists a zero in data. Therefore, if we want to include a zero with tick in ... Read More

How to change the order of elements in a list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Feb-2021 08:01:50

2K+ Views

A list in R can contain many types of elements such as vector, data frame, matrices, etc. Sometimes the order of these elements matter, especially in situations when we have large size elements because it is difficult to view large size elements of a list. This ordering can be done ... Read More

How to check if a variable contains number greater than 1 in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 10:55:19

2K+ Views

The variables in an R data frame are referred to as the columns of the data frame. Sometimes we have a threshold value for a particular column and we need to check whether all the values in that column are greater than or less than the threshold. For this purpose, ... Read More

How to create a random sample of week days in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 10:52:32

472 Views

To create a vector of weekdays we can use the command weekdays(Sys.Date()+0:6) and if we want to create a random sample of week days then sample function can be used along with the weekdays command. For example, if we want to create a random sample of 20 days then it ... Read More

How to replace missing values with row means in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 10:49:08

868 Views

If we have similar characteristics in each column of an R data frame then we can replace the missing values with row means. To replace the missing values with row means we can use the na.aggregate function of zoo package but we would need to use the transposed version of ... Read More

How to find the sum by distinct column for factor levels in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 10:44:52

720 Views

If the data frame contains a factor column and some numerical columns then we might want to find the sum of numerical columns for the factor levels. For this purpose, we can use aggregate function. For example, if we have a data frame df that contains a factor column defined ... Read More

How to change the repeated row names and column names to a sequence in a matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 10:37:08

548 Views

To change the repeated row names and column names to a sequence, we first need to read those names in a vector then set them to row names and column names with make.unique function. For example, if a matrix has row names defined as A, B, A, B, A then ... Read More

How to create a line chart with mean and standard deviation using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 05-Feb-2021 10:28:10

3K+ Views

Sometimes we have mean and standard deviation given for groups or factors, these are generally obtained from previous research studies and is referred to as the secondary data. In this case. the line chart with mean and standard deviation using ggplot2 can be created by defining the minimum and maximum ... Read More

Advertisements