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
read.url <- function(url, ...){ | |
temporaryFile <- tempfile() | |
download.file(url, destfile = temporaryFile, method = "curl") | |
url.data <- read.csv(temporaryFile, ...) | |
return(url.data) | |
} |
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
grep -Eiorh '[a-zA-Z]{1}[a-zA-Z0-9_\.\-]{1,26}@[a-zA-Z0-9_\.\-]+\.(?:[a-zA-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$' mbox | sort | uniq > emails.txt |
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
iqcor <- matrix(.5, nrow=2, ncol=2) | |
diag(iqcor) <- 1 | |
iqcor | |
require(MASS) | |
mvrnorm(10, mu=c(100, 100), Sigma=100*iqcor) |
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
# libraries used. install as necessary | |
library(shiny) | |
library(RJSONIO) # acquiring and parsing data | |
library(ggplot2) # graphs | |
library(plyr) # manipulating data | |
library(lubridate) #dates | |
library(stringr) | |
trim.leading <- function (x) sub("^\\s+", "", x) |
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
no_missing <- function(x) sum(is.na(x)) |
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
row.sample <- function(dta, rep = 20) { | |
dta <- as.data.frame(dta) # for single variables | |
dta[sample(1:nrow(dta), rep, replace=FALSE), ] | |
} |
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
table() | |
prop.table(mytable) # cell percentages | |
sort(table(x), decreasing = TRUE) | |
# Show missing data in table as default | |
table = function (..., useNA = 'ifany') base::table(..., useNA = useNA) |
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
Sub Test_NamedRanges() | |
For Each nm In ThisWorkbook.Names | |
If nm.RefersToRange.Parent.Name = Sheet10.Name Then MsgBox nm.Name | |
Next nm | |
End Sub |
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
# Simple charts | |
library(magrittr) | |
d <- rnorm(1000, 1, 1) | |
density(d) %>% plot | |
d2 <- rlnorm(1000, 1, 1) | |
density(d2) %>% plot |
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
loc <- function(x) { log(m^2 / sqrt(s^2 + m^2)) } | |
shape <- function(x) { sqrt(log(1 + (s^2 / m^2))) } |
OlderNewer