In this post we will learn how to replace NAs, i.e. missing values with zeros in data frame in R. With tidyr’s replace_na() function, we can replace NAs in specific columns of a dataframe to zero or any other specific value. We will start with learning how to use replace_na() to replace NAs in a… Continue reading How to replace NAs with zero in a dataframe
How to compute inverse of a matrix in R
In this tutorial, we will show how to compute inverse of matrix in R. Computing inverse of a matrix is core to multiple applications. In linear algebra, inverse of a matrix is defined as a matrix that, when multiplied by the original matrix, results in the identity matrix. In other words, if A is a… Continue reading How to compute inverse of a matrix in R
tidyr unite(): combine multiple columns into one
In this tutorial, we will learn how to use unite() function in tidyr package to combine multiple columns into a single column. By combining , we mean to concatenate the values of two or more columns separated by a delimiter like underscore. We will start with combining two columns into one column using three examples.… Continue reading tidyr unite(): combine multiple columns into one
How to add Prefix/Suffix to Column Names of a dataframe in R
In this tutorial we will learn how to add a prefix or a suffix to column names of a data frame in R. We will use dplyr’s rename_with() function to add prefix/suffix to column names. dplyr’s rename_with() function belongs to another renaming function in dplyr, rename() that is useful. for renaming a individual columns. First,… Continue reading How to add Prefix/Suffix to Column Names of a dataframe in R
How to Measure Running Time in R (with two examples)
In this tutorial, we will learn how to measure execution time in R. We will learn two ways, using Sys.time() and system.time, of measuring execution time in R. Both the methods to measure running time are readily available in base R and do need use any outside R packages. Measuring Execution Time with Sys.time() We… Continue reading How to Measure Running Time in R (with two examples)