Nizamuddin Siddiqui has Published 2307 Articles

How to set the plot area to assign the plots manually in base R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 13:38:43

79 Views

We can split the screen to assign the plots manually in the plot area. The split.screen function can be used for this purpose. For example, if we want to create 4 plots in the plot window then we can use split.screen(c(2, 2)). Now to create the plot in first screen ... Read More

How to convert multiple columns into single column in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 12:57:19

9K+ Views

To convert multiple columns into single column in an R data frame, we can use unlist function. For example, if we have data frame defined as df and contains four columns then the columns of df can be converted into a single by using data.frame(x=unlist(df)).Example1 Live DemoConsider the below data frame ... Read More

How to replace the outliers with 5th and 95th percentile values in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 12:57:04

294 Views

There are many ways to define an outlying value and it can be manually set by the researchers as well as technicians. Also, we can use 5th percentile for the lower outlier and the 95th percentile for the upper outlier. For this purpose, we can use squish function of scales ... Read More

How to remove rows for categorical columns that has three or less combination of duplicates in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 12:55:16

299 Views

In Data Analysis, we sometimes decide the size of the data or sample size based on our thoughts and this might result in removing some part of the data. One such thing could be removing three or less duplicate combinations of categorical columns and it can be done with the ... Read More

How to find the percentage of missing values in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 12:55:10

919 Views

To find the percentage of missing values in an R data frame, we can use sum function with the prod function. For example, if we have a data frame called df that contains some missing values then the percentage of missing values can be calculated by using the command: (sum(is.na(df))/prod(dim(df)))*100Example1 Live ... Read More

How to create a large vector with repetitive elements of varying size in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 12:51:52

329 Views

To create a large vector of repetitive elements of varying size we can use the rep function along with the logical vector as an index. The logical vector that contains TRUE or FALSE will define the selection or omission of the values in the vector created with the help of ... Read More

How to add a new value to each element of list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 12:51:43

666 Views

Suppose we have a list that contain two elements and we get a new value for both of these elements then the problem of adding those values to the original list arises. This can be done with the help of mapply function. We can append the new values in the ... Read More

How to create combinations of 0 and 1 with fixed number of 1s in each row in an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 12:48:13

353 Views

To create the combinations of 0 and 1 data frame, we can use expand.grid function along with the rep function. If we want to create combination of 0 and 1 with fixed number of 1’s in each row then rowSums functions can be used with the appropriate sum value. For ... Read More

How to create a sparse matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 12:45:57

4K+ Views

A sparse matrix is a type of matrix that has most of the elements equal to zero but there is no restriction for the number of zero elements. As a general criterion the number of non−zero elements are expected to be equal to the number of rows or number of ... Read More

How to convert a sparse matrix into a matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 08-Feb-2021 12:45:46

2K+ Views

A sparse matrix is a type of matrix that has most of the elements equal to zero but there is no restriction for the number of zero elements. As a general criterion the number of non-zero elements are expected to be equal to the number of rows or number of ... Read More

Advertisements