In this tutorial we will learn how to use dplyr’s between() function to find if one or more numerical values are in a range using multiple examples. We will first start with a single numeric value and find out if it is within a range. And then in the next example, we will use a… Continue reading dplyr between(): find if numerical values are within a range.
Category: dplyr
How to Randomly Replace Values of Numerical Columns in a dataframe to NAs
In this tutorial, we will learn how to randomly replace values of numerical columns in a dataframe to NAs or missing values. We will use dplyr’s across() function to select only the numerical columns from a dataframe and probabilistically select certain percent of elements to change to NAs. First, let us load tidyverse packages and… Continue reading How to Randomly Replace Values of Numerical Columns in a dataframe to NAs
dplyr contains(): select columns that contains a string
In this tutorial, we will learn how to select columns, whose names contains a string using dplyr’s contains() function. dplyr’s contains() function belongs to a family helper functions to select columns like starts_with() and ends_with(). First we will see a simple example of using single string and selecting all columns that contains the string. And… Continue reading dplyr contains(): select columns that contains a string
dplyr transmute(): add new columns and delete existing columns
In this tutorial, we will learn how to create new columns and remove existing columns using dplyr’s transmute() function. We will start with an example showing how to use transmute to create one new column and then show an example of creating more than one new column. First, let us load tidyverse, the suite of… Continue reading dplyr transmute(): add new columns and delete existing columns
dplyr’s mutate(): How to create new columns
In this tutorial, we will learn how to create/add one or more columns to a dataframe using dplyr’s mutate() function. We will first see an example of creating a single new column in a dataframe and then see an example of adding multiple columns using mutate() function. First we load tidyverse the suit of R… Continue reading dplyr’s mutate(): How to create new columns