Skip to content

Instantly share code, notes, and snippets.

View summerofgeorge's full-sized avatar
👼

George Mount summerofgeorge

👼
View GitHub Profile
#necessary packages
library(DescTools)
library(RDCOMClient)
#download file from https://drive.google.com/file/d/1kn49DDrn4KR1LshGGT8BjD6J3gPcl1Mk/view?usp=sharing/
iris<-read.csv("iris.csv")
#data manipulation/analysis ensues...
#..and now we're ready bring back to Excel...
> str(XLView)
function (x, col.names = TRUE, row.names = FALSE, na = "")
@summerofgeorge
summerofgeorge / RedYellowGreen.vb
Last active January 2, 2018 22:39
Color Cells Red/Yellow/Green in Excel
Sub Green()
Selection.Interior.ColorIndex = 10
End Sub
Sub Red()
Selection.Interior.ColorIndex = 3
End Sub
Sub Yellow()
Selection.Interior.ColorIndex = 27
@summerofgeorge
summerofgeorge / Equality testing - R.R
Last active January 2, 2018 22:38
Equality testing - R
x<-c(1,2,3)
y<-c(1,2,3)
x==y
a<-c(1,2,3)
b<-c(1,2,3)
a==b
@summerofgeorge
summerofgeorge / loopingfilesinr.r
Created January 17, 2018 13:00
Loop through files in R and apply functions
#perform a function on each file
#https://www.r-bloggers.com/perform-a-function-on-each-file-in-r/
setwd("H:/sample")
list.files("H:/sample")
fileNames<-Sys.glob("*.csv")
fileNames
@summerofgeorge
summerofgeorge / rtftotxt.r
Last active February 4, 2018 17:58
convert rtf files to txt in R
library(striprtf)
#get list of all RTF FILES ONLY in the folder
files <- list.files("C:/Factiva", pattern = "\\.rtf$")
#loop through files
for(file in files){
#read RTF into R
x <- read_rtf(file)
#strip RTF encoding
@summerofgeorge
summerofgeorge / kwic-loop.r
Last active May 14, 2018 12:06
Loop through dictionary for keyword in context of each item in the corpus
#simple example - no loop
#https://docs.quanteda.io/reference/kwic.html
library(quanteda)
library(readtext)
corp <- readtext::readtext("C:/FactivaOut")
c <- corpus(corp)
@summerofgeorge
summerofgeorge / LaunchHarvardGI
Last active May 11, 2018 17:08
Launch Harvard General Inquirer
#http://wjh.harvard.edu/~inquirer/j1_1/
#must have Java installed
#from command prompt:
\cd GeneralInquirer\
C:\GeneralInquirer>java -mx128m giGui
@summerofgeorge
summerofgeorge / SkewKurtos1.vb
Created June 2, 2018 17:23
SkewKurtos Part 1
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set rng = Target
Call Extras
End Sub
@summerofgeorge
summerofgeorge / SkewKurtoseStatus.vb
Last active June 2, 2018 18:15
SkewKurtose VBA Part 2
Public NoBlank As Long
Public Skewn As Double
Public Kurtos As Double
Public Stdev As Double
Public rng As Range
Public iAreaCount As Integer
Sub Extras()