Skip to content

Instantly share code, notes, and snippets.

library(tidyverse)
library(tidygeocoder)
library(ggmap)
library(viridis)
# import a dataset that has addresses in this format: "123 Royal Drive, Mesa, AZ 85206."
# If the address values are in separate columns (address, city, state, zip) you can use
# dplyr::mutate and paste to build the combined address:
# mydata <- mydata %>% mutate(address = paste0(add1,", ",city,", ",state," ",zip))
@aaroncharlton
aaroncharlton / sinha-wang-2013.r
Created March 23, 2022 13:02
Simulations of Sinha & Wang 2013
# recreate summary statistics - table 1
set.seed(123)
lonely_tib <- tibble(mean = rep(NA,1000),
sd = rep(NA, 1000))
for(i in 1:1000){
lonely <- rnorm(n = 153/3, mean = 0, sd = 1)
lonely_tib$mean[i] <- mean(lonely)
lonely_tib$sd[i] <- sd(lonely)
}
library(readr)
studentexperience <- read_csv("https://aaroncharlton.com/wp-content/uploads/2020/04/survey_responses.csv")
se_meta <- read_csv("https://aaroncharlton.com/wp-content/uploads/2020/04/survey_questions_meta.csv")
View(studentexperience)
# install.packages("tidyverse")
library(tidyverse)
studentexperience2 <- studentexperience %>%
rename(years_since_starting = `Year since Matriculation`,
year_in_school = `Year of Study`,
# first, look at the data
iris
head(iris)
summary(iris)
?iris
# next, visualize the data
library(ggplot2) # if not installed, run this code: install.packages("ggplot2")
ggplot(iris, aes(y = Sepal.Length, x = Petal.Length)) +
geom_point() +
mtcars
?mtcars
names(mtcars)
# Goal: Maximize mpg
model2 <- lm(mpg ~ wt+hp, data = mtcars)
summary(model2)
37-3.9*2.6-.03*110
setwd("~/Research/PPAuthenticity/studies/Study1")
library(dplyr)
filter <- dplyr::filter
select <- dplyr::select
qualtrics <- read.csv("PPAuthenticity2SPAPR15.csv", stringsAsFactors = FALSE) %>%
filter(grepl("^95", ID)) %>% # remove responses without student ID
rename(adskep_2 = adskep_10,
adskep_3 = adskep_11,
adskep_4 = adskep_12,
adskep_5 = adskep_13,
# 1. You will need to do a one-time install of the dplyr package (code on next line).
# install.packages("dplyr")
# 2. make sure to name the student ID column "ID" in both files
# 3. files must have two header rows (qualtrics-style) and be in .csv format
# 4. update all three of the following variables and don't forget the quotes!
qualtrics_file <- "Authenticity2.csv"
demos_file <- "Spring 2015 Demos %28UPPER 3-8%29 (1).csv"
save_location <- "C:/Users/abc/Downloads"
### shouldn't need to modify below this line ####
<a href="http://taqueriaelpatoverde.com/">My friends' restaurant</a>
<i>Italic</i> versus <strong>Bold</strong>
<h1>Header 1</h1>
<h2>Header 2</h2>
<p>Regular paragraph</p>
<a href="https://twitter.com/aaroncharlton">Aaron's twitter page</a>
library(plyr)
type.1 <- NULL
p.values <- NULL
all.p <- NULL
for (j in 1:100){
for (i in 1:1000){
indy <- sample(1:2,29, replace=TRUE)
inter <- sample(1:2,31, replace=TRUE)
indy.c <- count(indy)[,2]
inter.c <- count(inter)[,2]