This file contains hidden or 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
| # | |
| # [2016-03-28] Challenge #260 [Easy] Garage Door Opener | |
| # https://www.reddit.com/r/dailyprogrammer/comments/4cb7eh/20160328_challenge_260_easy_garage_door_opener/ | |
| # Demo at http://www.r-fiddle.org/#/fiddle?id=83RtwcPP&version=1 | |
| # | |
| # Kory Becker 4/3/2016 | |
| # http://primaryobjects.com | |
| # | |
| # Valid states and commands. |
This file contains hidden or 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
| # | |
| # [2016-03-21] Challenge #259 [Easy] Clarence the Slow Typist | |
| # https://www.reddit.com/r/dailyprogrammer/comments/4bc3el/20160321_challenge_259_easy_clarence_the_slow/ | |
| # Demo at http://www.r-fiddle.org/#/fiddle?id=JwY7VC2k&version=1 | |
| # | |
| # Kory Becker 4/3/2016 | |
| # http://primaryobjects.com | |
| # | |
| keypad <- data.frame(c(1, 4, 7, 10), |
This file contains hidden or 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
| # | |
| # [2016-04-04] Challenge #261 [Easy] verifying 3x3 magic squares | |
| # https://www.reddit.com/r/dailyprogrammer/comments/4dccix/20160404_challenge_261_easy_verifying_3x3_magic/ | |
| # Demo at http://www.r-fiddle.org/#/fiddle?id=AgVxiDgU&version=1 | |
| # | |
| # Kory Becker 4/4/2016 | |
| # http://primaryobjects.com | |
| # | |
| magicSquare <- function(input) { |
This file contains hidden or 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
| CommonManager = { | |
| wordToNumber: function(word, arr) { | |
| var dict = { | |
| 'first': 1, | |
| 'second': 2, | |
| 'third': 3, | |
| 'fourth': 4, | |
| 'fifth': 5, | |
| 'sixth': 6, | |
| 'seventh': 7, |
This file contains hidden or 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
| --- | |
| title: "Single Variable Linear Regression R^2" | |
| output: html_document | |
| --- | |
| The following figure shows three data points and the best fit line: | |
| y = 3x + 2. | |
| The x-coordinate, or "x", is our independent variable and the y-coordinate, or "y", is our dependent variable. |
This file contains hidden or 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
| NBA <- read.csv('nba_train.csv') | |
| # Seems around 42 wins, the team has a good chance of making it to the playoffs. | |
| table(NBA$W, NBA$Playoffs) | |
| NBA$PTSdiff <- NBA$PTS - NBA$oppPTS | |
| WinsReg <- lm(W ~ PTSdiff, data = NBA) | |
| PointsReg <- lm(PTS ~ X2PA + X3PA + FTA + AST + ORB + DRB + TOV + STL + BLK, data=NBA) | |
| SSE <- sum(PointsReg$residuals^2) |
This file contains hidden or 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
| data <- read.csv('climate_change.csv') | |
| train <- subset(data, Year <= 2006) | |
| test <- subset(data, Year > 2006) | |
| fit <- lm(Temp ~ MEI + CO2 + CH4 + N2O + CFC.11 + CFC.12 + TSI + Aerosols, data=train) | |
| fit2 <- lm(Temp ~ MEI + TSI + Aerosols + N2O, data=train) | |
| # Auto-create model (note, step does not address the collinearity of the variables, so some features removed in fit2 are present in this model). | |
| fit3 <- step(fit) |
This file contains hidden or 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
| train <- read.csv('pisa2009train.csv') | |
| test <- read.csv('pisa2009test.csv') | |
| tapply(train$readingScore, train$male, mean) | |
| # Which columns have an NA value? | |
| which(unlist(lapply(train, function(x) any(is.na(x))))) | |
| # Remove missing values. | |
| train <- na.omit(train) |
This file contains hidden or 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
| train <- read.csv('flutrain.csv') | |
| test <- read.csv('flutest.csv') | |
| train[order(train$ILI),] | |
| train[order(train$Queries),] | |
| hist(train$ILI) | |
| plot(log(train$ILI), train$Queries) |
This file contains hidden or 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
| --- | |
| title: "Logistic Regression Intro" | |
| output: html_document | |
| --- | |
| Suppose the coefficients of a logistic regression model with two independent variables are as follows: | |
| B0 = -1.5 | |
| B1 = 3 | |
| B2 = -0.5 |