Nizamuddin Siddiqui has Published 2307 Articles

How to find the sum of values based on key in other column of an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Feb-2021 08:23:34

538 Views

If we have a column that is key that means we want to use that column as an independent variable and find the statistical values such as sum, mean, standard deviation, range, etc. for the dependent variable. This can be done with the combination of with and tapply function as ... Read More

How to extract unique values in multiple columns in an R data frame using a single line code?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 06-Feb-2021 08:20:16

2K+ Views

To extract unique values in multiple columns in an R data frame, we first need to create a vector of the column values but for that we would need to read the columns in matrix form. After that we can simply unique function for the extraction. To understand how it ... Read More

How to split comma separated values in an R vector?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

9K+ Views

The splitting of comma separated values in an R vector can be done by unlisting the elements of the vector then using strsplit function for splitting. For example, if we have a vector say x that contains comma separated values then the splitting of those values will be done by ... Read More

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

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

309 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 change the name of a data frame in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

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

6K+ Views

To change the name of a data frame, we can set the original name to the new name. Now both of the names can be used. Most of the times the purpose behind changing the name of the data frame is that, the original name does not seem to be ... 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

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

290 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

Advertisements