dplyr ends_with(): select columns that end with a suffix

In this tutorial, we will learn how to select columns that ends with a string with multiple examples using dplyr and base R. With dplyr, we can use ends_with(), one of the select helper functions, to select columns that ends with a prefix/string. Similarly, in base R we have endsWith() function to help select column… Continue reading dplyr ends_with(): select columns that end with a suffix

How to collapse multiple rows based on a column

In this tutorial, we will learn how to collapse multiple rows from a column to a single row based on another column/group. Let us get started by loading tidyverse and checking the tidyr package version. To illustrate collapsing multiple rows into single one, let us create a toy dataframe with continents and countries. Our aim… Continue reading How to collapse multiple rows based on a column

How to Separate a Column into Multiple Rows in R: Hint tidyr’s spearate_row()

In this tutorial, we will learn how to separate a column with multiple elements separated by a delimiter into different rows. We will use tidy’s separate_rows() function first to separate a column with comma separated elements. And then show how to use separate_rows() on multiple columns. We will also see how to make separate_rows() function… Continue reading How to Separate a Column into Multiple Rows in R: Hint tidyr’s spearate_row()

How to select columns that starts with a prefix/string in R

In this tutorial, we will learn how to select columns that starts with a prefix or string using dplyr’s strats_with() function and base R startsWith() function. The tidyverse R package dplyr has a number of helper functions to select columns of interest under different condition. dplyr’s starts_with() function is one of select helper functions to… Continue reading How to select columns that starts with a prefix/string in R

How to Select Rows of a dataframe by position

In this post, we will see how to subset a dataframe or select rows based on their position. We will first use dplyr’s slice() function to slice a dataframe by location and then show how to select rows by position using base R Let us load tidyverse suite of R packages including dplyr. We will… Continue reading How to Select Rows of a dataframe by position

Exit mobile version