In this tutorial, we will learn how to convert a data matrix to tidy long table. We will use tidyr’s pivot_longer() function to reshape the matrix into a tidy table. First, let us start with loading the tidyverse suit of packages. Create a simulated data matrix Let us create a data matrix using rnorm() function… Continue reading How to convert a matrix to a tidy table
Category: tidyr
pivot_longer on dataframe with single row
In this tutorial, we will see an example of using pivot_longer() function to reshape, a dataframe with a single row, from wide form to long tidy form. Sometimes you might have a dataframe with just one long row and it is useful to reshape into longer format. We will start with creating a dataframe with… Continue reading pivot_longer on dataframe with single row
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()