In this post, we will learn how to use dplyr's rows_update() function with examples. dplyr's rows_update() function is a useful function to modify or update specific rows in a data frame based on a matching values in key column. It takes in two dataframes x and y, updates … [Read more...] about dplyr rows_update(): Modify existing rows
dplyr
dplyr n_distinct(): count unique elements or rows
In this post, we will learn how to use dplyr's n_distinct() function to count the number of unique or distinct values in one or more vectors or columns of a dataframe. dplyr's n_distinct() is very useful when you are working with a dataframe and need to know how many unique … [Read more...] about dplyr n_distinct(): count unique elements or rows
How to select top and bottom rows by a column simultaneously
In this tutorial, we will learn how to select top and bottom rows of a dataframe based on the values of a column with tidyverse in R. Here we will see a specific approach to get top and bottom rows when the values of the column of interest has both positive and negative values. … [Read more...] about How to select top and bottom rows by a column simultaneously
How to convert a list to a dataframe
In this tutorial, we will learn 3 different ways to convert a list object into a dataframe in R. First we will show how to use the base R function as.data.frame() to convert a list to a dataframe. Then we will show examples using map_df() function in purrr package in tidyverse … [Read more...] about How to convert a list to a dataframe
dplyr’s anti_join() to find rows based on presence or absence in a dataframe
In this tutorial, we will learn how to use dplyr's anti_join() function to filter rows from one dataframe based on the presence or absence of matches in another dataframe. dplyr's anti_join() function is extremely useful for cases when we want to find what row is present or … [Read more...] about dplyr’s anti_join() to find rows based on presence or absence in a dataframe