In this tutorial, we will learn how to compute annualized return of stock using tidyverse from scratch. Annualized return of an investment is the average returns of the investment that is held over many years. In comparison to simple mean of yearly returns, annualized return is … [Read more...] about How to compute annualized return of a stock with tidyverse
rstats101
How to get product of all elements in a column
In this tutorial we will learn how to compute product of all elements of a column in a dataframe using tidyverse. We will use prod() function in base to multiple all elements of a columns. Let us first load tidyverse. We will create a simple dataframe using tidyverse' … [Read more...] about How to get product of all elements in a column
slice_min: Get Rows with minimum values of a column
In this tutorial, we will learn how to get rows with lowest values of a column from a data frame in R. We will use dplyr's slice_min() function to select rows with lowest values for a column in a data frame. We will also use slice_min() function in dplyr to find the bottom n … [Read more...] about slice_min: Get Rows with minimum values of a column
Many linear regression models with tidyverse
In this tutorial, we will learn how to build many simple linear regression models in R using tidyverse. We will start with a simple approach that is not scalable to illustrate the challenges. Then we will show a naive approach using for loop to build many linear regression … [Read more...] about Many linear regression models with tidyverse
How to do inner join with dplyr in R
In this post, we will learn how to do an inner join in R with dplyr's inner_join(). An inner join between two dataframes x and y, gives is the only rows from x for which we have a matching key in y. First, load tidyverse suit of packages and check the version of dplyr … [Read more...] about How to do inner join with dplyr in R