Home

How to update your RStudio version with one function (from the installr package)

Packages we will need: According to the CRAN package for installr, “While for Linux users, the installation process of new software may be just running a short line of code, for the regular Windows user it often includes All of these steps are automatically done using functions in this package.” Click here to read the…

From loop to purrr

The first instinct for many R users (especially those coming from other programming languages) is to use run of the mill for loop: This works fine. It loops through country_1 to country_8, checks if each column exists, and converts the country names into COW codes. Buuut there’s another way to do this. Enter purrr and…

How to use the assign() function in R

We can use the assign function to create new variables. Most often I want to assign variables that I create to the Global Environment. assign particularly useful in loops, simulations, and scenarios involving conditional variable naming or creation. The basic syntax of the assign function is assign(x, value, pos = -1, envir = as.environment(pos), inherits…

How to run decision tree analysis with xgboost in R (Tidymodels Series PART 3)

Packages we will need: In this blog post, we are going to run boosted decision trees with xgboost in tidymodels. Boosted decision trees are a type of ensemble learning technique. Ensemble learning methods combine the predictions from multiple models to create a final prediction that is often more accurate than any single model’s prediction. The…

How to run linear regression analysis with tidymodels in R for temporal prediction (Tidymodels Series PART 2)

Packages we will need: We will look at Varieties of Democracy dataset We will create two datasets: one for all years EXCEPT 2020 and one for only 2020 First we build the model. We will look at whether level of public sector theft can predict the judicial corruption levels. The model will have three parts…