In this post, we will learn how to drop unused level or levels of a factor variable in R. Sometimes, we may end up with a factor variable with un used levels after some data munging. Unused factor levels can sometime create issues while analyzing the data. In this tutorial, we will show how to… Continue reading How to drop unused level of factor variable in R
Category: tidyverse
T-test on real data using tidyverse
In this post, we will learn how to perform t-test on a real dataset and use tidyverse framework to access results from t-test. Check out the post how to do t-test to learn base R approach to t-tes. We will use Palmer penguin dataset, a real world dataset, to show how to perform t-test. First,… Continue reading T-test on real data using tidyverse
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 and bind_rows() function in… Continue reading How to convert a list to a dataframe
How to add currency symbols to columns of a table with gt()
In this tutorial, we will learn how to add currency symbols, like US dollars, Euro, UK pound, Indian Rupee to columns of a table using the R package gt. Let us load gt package to make beautiful tables and tidyverse. First we will create a simple dataframe/tibble with stock prices of a few companies in… Continue reading How to add currency symbols to columns of a table with gt()
How to sort columns alphabetically
In this tutorial, we will learn how to sort columns of a dataframe in alphabetical order. We will first use tidyverse to sort columns of a dataframe using two different ways. And then we will see how to use base R functions to sort the columns. Let us load tidyverse. We will use starwars that… Continue reading How to sort columns alphabetically