Last active
July 5, 2018 23:05
-
-
Save FthrsAnalytics/40ea846ae96445eb9b39b6aaf3b83d9b to your computer and use it in GitHub Desktop.
Power BI & R - Data Connector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(readxl) | |
library(dplyr) | |
library(broom) | |
data <- read_excel("C:/Users/jfthr/Google Drive/Feathers Analytics/R Visuals Presentation/R Visuals Power BI Fantasy.xlsx") | |
model_data <- data %>% | |
select(Player, TeamGroup, Price, Selected, Points, MP) | |
top_teams <- model_data %>% | |
filter(TeamGroup == "Top") | |
top_fit <- lm(Points ~ Price + Selected + MP, top_teams) | |
bottom_teams <- model_data %>% | |
filter(TeamGroup == "Bottom") | |
bottom_fit <- lm(Points ~ Price + Selected + MP, bottom_teams) | |
top_tidied <- tidy(top_fit) | |
bottom_tidied <- tidy(bottom_fit) | |
top_tidied$model <- "top" | |
bottom_tidied$model <- "bottom" | |
visual_data <- bind_rows(top_tidied, bottom_tidied) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment