R programming language uses $ operator (dollar operator) for extracting or accessing elements from data structures like list or dataframe. For example, with $ operator we can select specific elements of a list or dataframe by their names instead of their position. In this post, we will learn two most common uses of $ operator… Continue reading How to use dollar $ operator in R
Category: rstats101
How to compute mean in R
In this tutorial, we will learn how to use mean() function in R to compute mean (or average) of a vector. In the most basic use case, mean() function takes a vector as input argument and computes arithmetic mean of the elements in the vector In R, we can learn more about the function with… Continue reading How to compute mean in R
How to calculate cumulative sum in R
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 sum of a column… Continue reading 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 will… Continue reading dplyr rename(): How to rename column in r with dplyr
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 numerical variable into a categorical variable with multiple levels. Let… Continue reading How to Convert Numerical Variable into a Categorical Variable in R