Skip to content

Instantly share code, notes, and snippets.

@ZeccaLehn
ZeccaLehn / Find_Packages.md
Last active August 29, 2015 14:04
Finds unique packages within .Rmd files, from multiple subdirectories
# #Majority Vote Accuracy
# For Johns Hopkins / Machine Learning in R
# n <- 5 # Independent Classifiers
# k <- 3 #
#
# accuracy <- 0.7
#
# majorityAccu(5, 3, .7) # 83.7% Accuracy
# majorityAccu(101, 51, .7) #99.9% Accuracy
@ZeccaLehn
ZeccaLehn / CompressionComparisons.md
Last active August 29, 2015 14:12
Compression Comparisons in R -- Research

Code I presented in Johns Hopkins Data Science Capstone:

Size of compressed file as percentage of the original file

                   Adaptive 
                   Huffman Lempel-Ziv
     LaTeX file     66%      44%
     Speech file     65%     64%
     Image file      94%     88%

http://www.data-compression.com/lossless.html
@ZeccaLehn
ZeccaLehn / Search R Packages by Letter
Created December 29, 2014 17:04
Search R Packages by Letter
#Search installed packages by first letter -- regardless of upper/lower case (by 's' here)
grep("^[s]", attributes(installed.packages())$dimnames[[1]], value = TRUE, ignore.case = TRUE)
@ZeccaLehn
ZeccaLehn / BINOMIAL_PROBABILITIES
Last active August 29, 2015 14:13
BINOMIAL PROBABILITIES
# Quick GIST I wrote in the Data Science Capstone JHU forum (Dec 2014)
# It appears if the one of us draws 5 random tweets or news excerpts as the grading criteria calls for,
# the probability that none of the five match the top-word is 32.8%--assuming the
# true accuracy of model is 20%.
# Overall, if the top-word as criteria for success is used, where 4 reviewers using 5 random samples,
# the probability that none of the 20 predictions match the top word is only 1.2%.
@ZeccaLehn
ZeccaLehn / stringToChar.r
Last active August 29, 2015 14:13
String to Characters in R -- "Hello World" Function
stringToChar<- function( example ){
example <- as.character(example)
letters <- strsplit(example,"")[[1]]
for (i in letters[1:length(letters)] ) { print(i) }
}
@ZeccaLehn
ZeccaLehn / ExploreHiddenR.md
Last active December 1, 2020 15:23
[R] Explore Hidden Environments and Functions -- by example

Shows function Internals

library(BayesianFirstAid)
debugonce(bayes.t.test) # turns off debugging for function after first run
bayes.t.test(co2)

Returns hidden and unhidden environments

@ZeccaLehn
ZeccaLehn / AutomagicDir.md
Last active August 29, 2015 14:15
Automagically Set R Working Directory on Linux Machine

Sets the working directory in R on a Linux system after and are replaced with actual folder names.

Alows for sharing code without each user having to change the HOME variable (e.g., "home/myMachine/Projects/First"

setwd(paste0(Sys.getenv("HOME"),"/<TopDir>/<Root>")) 

For Windows, use proper slash direction and notation.

@ZeccaLehn
ZeccaLehn / beeprExample.md
Created March 1, 2015 01:07
[R] Beeps when ready

Calls a sound -- useful when waiting...

install.packages("beepr")
library(beepr)
beep(sound = 3, expr = NULL) #Fanfare!!

1: "ping"

@ZeccaLehn
ZeccaLehn / shillerHousingAPI.ipynb
Last active June 29, 2016 20:10
[R] Case Shiller (Yale) US Housing and Economic API
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.