Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Commit 67494b8

Browse files
author
Adam Kaplan
committed
Added ugly code example
Created a separate analysis.R file to showcase the impact readability has.
1 parent 44ee7f7 commit 67494b8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

analysis/analysis_UGLY.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library(readr)
2+
library(ggplot2)
3+
library(stargazer)
4+
5+
simdata <- read_csv("C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices/PML_Good_coding_practices_example/data/simulated-data.csv")
6+
reg=lm(y~x+1,data=simdata)
7+
summary(reg)
8+
#stargazer(reg, out = "C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices/PML_Good_coding_practices_example/report/tables/regression.tex")
9+
10+
#png("C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices/PML_Good_coding_practices_example/report/figures/regression.png")
11+
plot(simdata$x, simdata$y)
12+
lines(simdata$x, predict(reg), col="red")
13+
#dev.off()
14+
15+
simdata$preds = predict(reg)
16+
ggplot(simdata, aes(x = x, y = y)) + geom_point() + geom_line(aes(y = preds), color = "red")
17+
#ggsave("C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices/PML_Good_coding_practices_example/report/figures/regression_ggplot.png")

0 commit comments

Comments
 (0)