Skip to content

Instantly share code, notes, and snippets.

View cdesante's full-sized avatar

Christopher DeSante cdesante

  • Indiana University
View GitHub Profile
@cdesante
cdesante / rPackages
Created April 24, 2020 14:49
Reinstalling All Packages for R 4.0
#In R 3.6, run:
.libPaths()[1]
#Copy this directory path and paste it on the line below;
#Then run all lines below in R 4.0:
PASTED <- "C:/Users/.../R/win-library/3.6"
currentPackages <- list.dirs(path = PASTED , recursive = FALSE)
currentPackages
trimmed <- stringr::str_replace_all(currentPackages, paste(PASTED , "/", sep = ""), "")
toInstall <- dput(trimmed)
doInstall <- TRUE
@cdesante
cdesante / newVersion.R
Last active June 6, 2019 14:51
newVersion
install.packages("tidyr", dependencies = TRUE)
install.packages("ggplot2", dependencies = TRUE)
install.packages("survey", dependencies = TRUE)
install.packages("gridExtra", dependencies = TRUE)
install.packages("dplyr", dependencies = TRUE)
install.packages("stringr", dependencies = TRUE)
install.packages("tidytext", dependencies = TRUE)
install.packages("mvtnorm", dependencies = TRUE)
install.packages("foreign", dependencies = TRUE)
install.packages("Zelig", dependencies = TRUE)
@cdesante
cdesante / turkey2016.r
Last active February 28, 2018 15:50
library(ggplot2)
theme_set(theme_bw())
Turkey <- read.csv("http://pages.iu.edu/~cdesante/turkey.csv")
ggplot(data = Turkey) + geom_tile(aes(x = Happy, y = Thanksgiving, fill=Turkey.Colors
)) + scale_fill_identity() + theme_bw() + labs(title = "Happy Thanksgiving 2016 from is.R()!\n",
x = "", y = "") + scale_x_continuous(breaks = NULL)+ scale_y_continuous(breaks = NULL)
@cdesante
cdesante / Rwords.r
Created December 17, 2012 16:01
Extracting Numeric Values from Words
My.Words <- read.csv("http://www.oberlin.edu/faculty/cdesante/assets/downloads/Randwords.csv")
My.Words$RANDOM.WORDS <- as.character(My.Words$RANDOM.WORDS)
#Step 1: Split Character Vectors into Sub-strings:
strsplit(My.Words$RANDOM.WORDS, "")
Split.List <- strsplit(My.Words$RANDOM.WORDS, "")
#Step 2: Assign a numeric value to each of the 26 letters:
LETTERS
@cdesante
cdesante / basicmap.r
Created December 10, 2012 17:55
basic map
doInstall <- TRUE
toInstall <- c("maps", "ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
library(ggplot2)
library(maps)
Prison <- read.csv("http://www.oberlin.edu/faculty/cdesante/assets/downloads/prison.csv")
head(Prison)
@cdesante
cdesante / apsrtable.r
Created December 4, 2012 00:19
apsrtable
doInstall <- TRUE
toInstall <- c("apsrtable")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
#http://cran.r-project.org/web/packages/apsrtable/apsrtable.pdf
library(apsrtable)
@cdesante
cdesante / apsrtable.r
Created December 4, 2012 00:00
apsrtable
doInstall <- TRUE
toInstall <- c("apsrtable")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
#http://cran.r-project.org/web/packages/apsrtable/apsrtable.pdf
library(apsrtable)
@cdesante
cdesante / foreign.r
Created December 3, 2012 20:11
foreignR
doInstall <- TRUE
toInstall <- c("foreign")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
#http://cran.r-project.org/web/packages/foreign/foreign.pdf
#setwd("your working directory here")
library(foreign)
@cdesante
cdesante / happythanksgiving.r
Created November 21, 2012 01:22
Thanksgiving
toInstall <- c("ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
library(ggplot2)
Turkey <- read.csv("http://www.oberlin.edu/faculty/cdesante/assets/downloads/turkey.csv")
ggplot(data = Turkey) + geom_tile(aes(x = Happy, y = Thanksgiving, fill=Turkey.Colors,
width=1))+ scale_fill_identity() + theme_bw()
@cdesante
cdesante / hjustvjust.r
Created November 14, 2012 05:52
hjustvjust
hjustvjust <- expand.grid(
hjust=c(0, 0.5, 1),
vjust=c(0, 0.5, 1),
angle=c(0, 45, 90),
text="is-R"
)
hv <- ggplot(hjustvjust, aes(x=hjust, y=vjust)) +
geom_point() +