Using RStudio – editing your user level and project level .RProfile file

Using the .Rprofile file in RStudio is a great way to automatically load packages and functions upon startup. If you know of additional ways to use this file, let me know. For now, here are easy ways to edit these files at each level. Very simply, use the usethis::edit_r_profile() command to edit your .RProfile file. It defaults to edit the user level file but you can add scope = c("user", "project") to the argument of the function....

R – how to select all rows of a data frame where a condition is met

Here is an example, the data looks like this with 3 columns. > fd_nba_raw Position Nickname Injury.Indicator 1 PG Luka Doncic 2 PF Giannis Antetokounmpo 3 C Karl-Anthony Towns GTD 4 SF Kevin Durant 5 SF LeBron James 6 PF Anthony Davis GTD 7 PG Kyrie Irving O 8 SG CJ McCollum 9 SF Kawhi Leonard 10 PG Damian Lillard GTD To select only those with Injury.Indicator = ‘O’ fd_nba_raw[fd_nba_raw$Injury.Indicator == 'O',] You can also include & and I (and & or) conditions....

AB or Hypothesis test comparing the mean of two samples (using R)

To compare means of two samples, we need to perform an independent samples t-test, more commonly called Student’s t-Test. To perform this test, we need to know some statistics about the samples: each sample’s mean (x̄), standard deviation (s), and sample size (n). Here is an example: There is data contained in a table of two columns. Column 1 is called ‘category’ and Column 2 is called ‘length.’ The category column contains two options, a and b, while the length column contains lengths in R type num....

How To Optimize a DFS Lineup using R and linear programming

This is a post explain how to optimize a Daily Fantasy Sports (DFS) lineup using R and associated R packages. This specific post will shows how to optimize a line for a 9 player MLB “classic” FanDuel contest. At the time of this writing (April 12, 2020) FanDuel is only offering Full Roster Sim contests because no live MLB games are being played at this time. Here is a link to the specific FanDuel contest I used when writing this guide....