gsub() in R to replace all matching patterns

In this tutorial, we will learn about gsub() function in R to replace all matching patterns in a string. gsub, stands for “global substitution” is similar to another function R, sub(), but for substituting all matching patterns, not just the first one. Here is a typical use of gsub() in R. We need to provide… Continue reading gsub() in R to replace all matching patterns

dplyr near(): compare if numbers and vectors are nearly the same

In this tutorial, we will learn near() function part of R package dplyr to check the equality of two numbers or vectors. Often we would like to compare if two numbers or two vectors are equal. A naive approach of using == to compare if two numbers are equal can be problematic due to machine… Continue reading dplyr near(): compare if numbers and vectors are nearly the same

dplyr’s arrange(): Sort a Dataframe Columns

Sort Dataframe by a Column in R

In this tutorial, we will learn how to sort a dataframe by a column in R. We will see three examples of using tidyverse’s arrange() function to sort a dataframe by one of its columns. First, we will sort a dataframe by numerical column in ascending order, next we will sort it in descending order… Continue reading dplyr’s arrange(): Sort a Dataframe Columns

Exit mobile version