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
> function(){x <- 1} | |
function(){x <- 1} | |
> x | |
Error: object 'x' not found | |
> y = 3 | |
> (function(x = 5 + y) x)() | |
[1] 8 | |
> x | |
Error: object 'x' not found |
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
# Data From https://stats.stackexchange.com/questions/64927/how-do-i-plot-an-exponential-curve-in-r | |
x = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
1,1,1,1,1,1,1,1,1,1,2,1,2,2,1,2,1,2,2,2,2,2,1,2,2, | |
1,3,1,3,1,2,1,2,2,3,3,2,3,3,3,2,3,3,2,1,5,5,1,4,3, | |
4,3,3,5,7,2,4,6,4,4,3,6,5,5,3,4,3,4,7,5,7,11,3,6, | |
6,6,9,1,1,3,9,3,4,6,6,12,6,2,12,8,2,4,12,6,8,9,6, | |
5,4,4,11,4,18,8,10,8,17,5,16,16,6,5,18,3,1,10,2, | |
11,21,8,11,15,9,13,14,3,11,17,18,9,16,17,12,18,2, | |
9,17,14,14,5,21,21,13,17,15,9,1,18,17,7,2,17,23,22, |
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
# Starting Order | |
> c(1, 2) %in% c(1,3,5) # Indexes left side | |
[1] TRUE FALSE | |
> c(1, 2) == c(1,3,5) # Same as above, but indexes right side | |
[1] TRUE FALSE FALSE | |
> ! c(1, 2) %in% c(1,3,5) | |
[1] FALSE TRUE | |
> union(c(1, 2), c(1,3,5)) | |
[1] 1 2 3 5 | |
> intersect(c(1, 2), c(1,3,5)) |
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
# Data Sampled from Bayesian AB Testing Article: http://varianceexplained.org/r/credible_intervals_baseball/ | |
hit_table <- data.frame(hits = c(0, 0, 4, 9, 28, 30), at_bat = c(3, 6, 10, 41, 130, 139)) | |
propTable <- function(inputData = inputData, correction = TRUE){ | |
prop_return <- apply(inputData, 1, function(x){ | |
prop_row <- prop.test(x[1], x[2], conf.level = 0.95, correct = correction) | |
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
###### Multiple Security Downloader with D3.js Plot ###### | |
library(quantmod) | |
# require(devtools) | |
# install_github('rCharts', 'ramnathv') | |
library(rCharts) | |
from = "2015-01-01" | |
to = "2016-01-01" |
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
# Static variable setting | |
eval(parse(text="adder1 <- 1 + 3; adder2 <- 1 + 4")) | |
adder1 # [1] 4 | |
adder2 # [1] 5 | |
# Dynamic variable setting | |
for(i in 1:2){ | |
print(paste0("adder", i, " <- ", i + 1)) | |
eval(parse(text = paste0("adder", i, " <-", i + 1))) | |
} |
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
Sys.time() | |
# [1] "2016-11-23 21:22:46 UTC" | |
as.POSIXct( as.numeric(Sys.time()), origin = "1970-01-01" ) | |
# [1] "2016-11-23 21:22:46 UTC" |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.