How to create a nested dataframe with lists

In this tutorial, we will learn how to create a nested dataframe using nest() function in tidyverse. A nested dataframe is a dataframe where one or more columns are list columns. In a simple dataframe, columns are simple/atomic vectors. However, column can contain other data structures like list, or dataframe. Such columns are called list… Continue reading How to create a nested dataframe with lists

expand_grid(): Create all possible combinations of variables

In this tutorial, we will learn how to create all possible combinations of two variables using tidyr’s expand_grid() function. For example, if we have two variables of interest and want to create a dataframe with all possible combinations of the values of the two variables, we can use expand_grid() function. let us get started by… Continue reading expand_grid(): Create all possible combinations of variables

tidyr’s separate_delim_wider(): Split a string into columns

In this tutorial, we will learn how to split a string in a column into multiple columns using a delimiter. We will use tidyr’s separate_delim_wider() function, that separates a string in a column into multiple columns using delimiter. After spliting the dataframe is wider with more columns. We will start with a simple example of… Continue reading tidyr’s separate_delim_wider(): Split a string into columns

How to replace NAs with zero in a dataframe

In this post we will learn how to replace NAs, i.e. missing values with zeros in data frame in R. With tidyr’s replace_na() function, we can replace NAs in specific columns of a dataframe to zero or any other specific value. We will start with learning how to use replace_na() to replace NAs in a… Continue reading How to replace NAs with zero in a dataframe

tidyr unite(): combine multiple columns into one

In this tutorial, we will learn how to use unite() function in tidyr package to combine multiple columns into a single column. By combining , we mean to concatenate the values of two or more columns separated by a delimiter like underscore. We will start with combining two columns into one column using three examples.… Continue reading tidyr unite(): combine multiple columns into one

Exit mobile version