Skip to content

Instantly share code, notes, and snippets.

View summerofgeorge's full-sized avatar
👼

George Mount summerofgeorge

👼
View GitHub Profile
@summerofgeorge
summerofgeorge / Closeallbutactiveworkbook.vb
Created June 16, 2018 01:20
Close all workbooks but active
'Source: Power programming VBA p86-87
Sub CloseInactive()
Dim Book as Workbook
For Each Book In Workbooks
If Book.Name <> ActiveWorkbook.Name Then Book.Close
Next Book
End Sub
@summerofgeorge
summerofgeorge / Expletive.R
Last active July 7, 2018 15:40
Expletive generator in R
#create a vector of characters we want to sample from
expl <- c("#","$","@","%","*","!")
#example - sample two characters
#and collapse the characters into one element
samp <- sample(expl,2)
samp2 <- paste(samp,collapse="")
samp2
#example function
@summerofgeorge
summerofgeorge / Expletive1.r
Created July 7, 2018 15:18
ExpletiveStep1
#create a vector of characters we want to sample from
expl <- c("#","$","@","%","*","!")
#example - sample two characters
#and collapse the characters into one element
samp <- sample(expl,2)
samp2 <- paste(samp,collapse="")
samp2
@summerofgeorge
summerofgeorge / Expletive3.r
Last active July 7, 2018 15:53
Expletive3
#example function
expletive <- function(nochars) {
expleti <- paste(sample(expl,nochars),collapse = "")
return(expleti)
}
#assign result of this function to a new variable
cursing <- expletive(5)
myfunction <- function(arg1, arg2, ... ){
statements
return(object)
}
@summerofgeorge
summerofgeorge / UDF-Example.r
Created July 23, 2018 01:22
UserDefinedFunctionRExample
#name.of.function <- function(argument1, argument2) {
# statements
# return(something)
#}
function()
library(reshape2)
library(dplyr)
#taveras p128
batting <- read.csv("C:/RFiles/baseball/batting.csv")
names(batting)
# keep stats for 2008 and onward
x = filter(batting, yearID >= 2008)
@summerofgeorge
summerofgeorge / rstudiotour.r
Created August 4, 2018 23:04
Tour of RStudio
1 + 1
x <- 2
#assign the sqrt of 25 to x
x <- sqrt(25)
x
help(sqrt)
@summerofgeorge
summerofgeorge / piechart.r
Created August 7, 2018 17:50
Pie Chart R Example
#PIE CHART
?pie
nycpop <- data.frame(borough = c("Manhattan", "Brooklyn", "Queens", "Bronx", "Staten Island"),
population = c(1.64, 2.63, 2.33, 1.46, .47))
#create a pie chart
nycpie <- pie(nycpop$population, labels = nycpop$borough)