In this tutorial, we will learn how to calculate cumulative sum in R. With cumsum() function in base R, we. can compute cumulative sum of a vector in R. We will first see two examples of using cumsum() on a vector to compute cumulative sum and then we will compute cumulative … [Read more...] about How to calculate cumulative sum in R
dplyr rename(): How to rename column in r with dplyr
In this tutorial, we will learn how to rename column name of a dataframe in R using dplyr's rename() function. We will first see the basic syntax to use to change the name of a column with dplyr's rename(). Then we will see an example of of changing one column name and next wee … [Read more...] about dplyr rename(): How to rename column in r with dplyr
How to convert a matrix to a tidy table
In this tutorial, we will learn how to convert a data matrix to tidy long table. We will use tidyr's pivot_longer() function to reshape the matrix into a tidy table. First, let us start with loading the tidyverse suit of packages. Create a simulated data matrix … [Read more...] about How to convert a matrix to a tidy table
How to Convert Numerical Variable into a Categorical Variable in R
In this tutorial, we will learn how to convert numerical or continuous variable into categorical variable. We will start with the simple example converting a numerical variable into a categorical variable with just two levels. And then we will see an example of converting a … [Read more...] about How to Convert Numerical Variable into a Categorical Variable in R
How to sort columns alphabetically
In this tutorial, we will learn how to sort columns of a dataframe in alphabetical order. We will first use tidyverse to sort columns of a dataframe using two different ways. And then we will see how to use base R functions to sort the columns. Let us load … [Read more...] about How to sort columns alphabetically