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 … [Read more...] about How to create a nested dataframe with lists
tidyr
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 … [Read more...] about 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 … [Read more...] about 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() … [Read more...] about 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 … [Read more...] about tidyr unite(): combine multiple columns into one