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

Commit 13ed7af

Browse files
author
Adam Kaplan
committed
Added presentation slides
Added workshop presentation slides and updated the README accordingly.
1 parent f8b29da commit 13ed7af

36 files changed

+870
-11
lines changed

.Rhistory

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,69 @@
11
setwd("C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices_example")
22
renv::init()
33
renv::snapshot()
4+
setwd("C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices/PML_Good_coding_practices_example")
5+
renv::activate()
6+
install.packages("styler")
7+
styler:::set_style_transformers()
8+
styler:::style_active_file()
9+
# Libraries and setup #######
10+
#
11+
library(here)
12+
library(readr)
13+
library(stargazer)
14+
library(ggplot2)
15+
# Let `here` know what file this is using RELATIVE paths
16+
here::i_am("analysis/analysis.R")
17+
# Analysis ##################
18+
#
19+
# Can use here to access data using RELATIVE paths
20+
data <- readr::read_csv(here("data/simulated-data.csv"))
21+
# Run regression
22+
regression <- lm(y ~ x + 1, data = data)
23+
# Outputs ###################
24+
#
25+
## Save table ###############
26+
summary(regression)
27+
stargazer::stargazer(regression, out = here("report/tables/regression.tex"))
28+
## Plot results #############
29+
### Base R version ##########
30+
png(here("report/figures/regression.png"))
31+
plot(data$x, data$y)
32+
lines(data$x, predict(regression), col = "red")
33+
dev.off()
34+
# Libraries and setup #######
35+
#
36+
library(here)
37+
library(readr)
38+
library(stargazer)
39+
library(ggplot2)
40+
# Let `here` know what file this is using RELATIVE paths
41+
here::i_am("analysis/analysis.R")
42+
# Analysis ##################
43+
#
44+
# Can use here to access data using RELATIVE paths
45+
data <- readr::read_csv(here("data/simulated-data.csv"))
46+
# Run regression
47+
regression <- lm(y ~ x + 1, data = data)
48+
# Outputs ###################
49+
#
50+
## Save table ###############
51+
summary(regression)
52+
stargazer::stargazer(regression, out = here("report/tables/regression.tex"))
53+
## Plot results #############
54+
### Base R version ##########
55+
png(here("report/figures/regression.png"))
56+
plot(data$x, data$y)
57+
lines(data$x, predict(regression), col = "red")
58+
dev.off()
59+
### GGplot version ##########
60+
plotting_data <- data
61+
plotting_data$predictions <- predict(regression)
62+
ggplot2::ggplot(plotting_data, aes(x = x, y = y)) +
63+
geom_point() +
64+
geom_line(aes(y = predictions), color = "red")
65+
ggplot2::ggsave(here("report/figures/regression_ggplot.png"))
66+
debugSource("C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices/PML_Good_coding_practices_example/analysis/analysis.R")
67+
plot(data$x, data$y)
68+
lines(datas$x, predict(regression), col = "red")
69+
print(datas$x)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"debugBreakpointsState": {
3+
"breakpoints": [
4+
{
5+
"id": 0,
6+
"path": "C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices/PML_Good_coding_practices_example/analysis/analysis.R",
7+
"line_number": 35,
8+
"function_steps": "",
9+
"function_name": "toplevel",
10+
"state": 1,
11+
"editor_state": 1,
12+
"editor_line_number": 35,
13+
"is_pending_debug_completion": false,
14+
"needs_updated_steps": true,
15+
"type": 1,
16+
"is_package_breakpoint": false,
17+
"package_name": ""
18+
},
19+
{
20+
"id": 3,
21+
"path": "C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices/PML_Good_coding_practices_example/analysis/analysis.R",
22+
"line_number": 39,
23+
"function_steps": "",
24+
"function_name": "toplevel",
25+
"state": 1,
26+
"editor_state": 1,
27+
"editor_line_number": 39,
28+
"is_pending_debug_completion": false,
29+
"needs_updated_steps": true,
30+
"type": 1,
31+
"is_package_breakpoint": false,
32+
"package_name": ""
33+
}
34+
]
35+
}
36+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"sortOrder": [
3+
{
4+
"columnIndex": 2,
5+
"ascending": true
6+
}
7+
],
8+
"path": "C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices/PML_Good_coding_practices_example"
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"activeTab": 1
3+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"left": {
3+
"splitterpos": 331,
4+
"topwindowstate": "NORMAL",
5+
"panelheight": 778,
6+
"windowheight": 816
7+
},
8+
"right": {
9+
"splitterpos": 480,
10+
"topwindowstate": "NORMAL",
11+
"panelheight": 778,
12+
"windowheight": 816
13+
}
14+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"TabSet1": 1,
3+
"TabSet2": 0,
4+
"TabZoom": {}
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build-last-errors="[]"
2+
build-last-errors-base-dir=""
3+
build-last-outputs="[]"
4+
compile_pdf_state="{\"tab_visible\":false,\"running\":false,\"target_file\":\"\",\"output\":\"\",\"errors\":[]}"
5+
files.monitored-path=""
6+
find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":false,\"ignoreCase\":false,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOn\":[],\"matchOff\":[],\"replaceMatchOn\":[],\"replaceMatchOff\":[]},\"running\":false,\"replace\":false,\"preview\":false,\"gitFlag\":false,\"replacePattern\":\"\"}"
7+
imageDirtyState="0"
8+
saveActionState="0"

.Rproj.user/D8C8E36F/rmd-outputs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
4+
5+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"active_set":"","sets":[]}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"id": "38D9610B",
3+
"path": "C:/Users/adamk/Dropbox (MIT)/Current/PML_Good_coding_practices/PML_Good_coding_practices_example/simulation/create-data.R",
4+
"project_path": "simulation/create-data.R",
5+
"type": "r_source",
6+
"hash": "1521040682",
7+
"contents": "",
8+
"dirty": false,
9+
"created": 1637353896550.0,
10+
"source_on_save": false,
11+
"relative_order": 1,
12+
"properties": {
13+
"source_window_id": "",
14+
"Source": "Source"
15+
},
16+
"folds": "",
17+
"lastKnownWriteTime": 1637247593,
18+
"encoding": "UTF-8",
19+
"collab_server": "",
20+
"source_window": "",
21+
"last_content_update": 1637247593,
22+
"read_only": false,
23+
"read_only_alternatives": []
24+
}

0 commit comments

Comments
 (0)