Skip to main content
Menu
Contents
Reproducible Research Using R: Title Page
Reproducible Research Using R
Title Page
Visibility
Show the following:
Annotations
Yours
Others
Your highlights
Resources
Show all
Reader Appearance
Adjust appearance:
Font
Font style
Serif
Sans-serif
Decrease font size
Increase font size
Decrease font size
Increase font size
Color Scheme
Light
Dark
Annotation contrast
abc
Low
abc
High
Margins
Increase text margins
Decrease text margins
Reset to Defaults
Search
Enter search criteria
Execute search
Search within:
chapter
text
project
Sign In
avatar
Edit Profile
Notifications
Privacy
Log Out
Project Home
Brooklyn Civic Data Lab
Projects
Sign In
Learn more about
Manifold
Notes
Close
table of contents
About
0.1 What You’ll Learn
0.2 What You Should Know First
0.3 What This Book Does Not Cover
How to Use This Book
0.4 Chapter Anatomy
0.5 Code, Data, and Reproducibility
0.6 Acknowledgments
1 Getting Started with R
1.1 Learning Objectives
1.2 RStudio
1.3 R as a Calculator
1.3.1 Basic Math
1.3.2 Built-in mathematical Functions
1.4 Creating Variables and Assigning Objects
1.5 Vectors
1.5.1 Numeric Vectors
1.5.2 Character Vectors
1.5.3 Logical Vectors
1.5.4 Factors (categorical)
1.5.5 Indexing (1-based in R!)
1.5.6 Type Coercion
1.6 Data Frames
1.6.1 Creating Your Own Data Frame
1.6.2 Functions to Explore Datasets
1.6.3 Working With Columns Within Data Frames
1.7 Reading & Writing data
1.8 Packages
1.9 Getting Comfortable Making Mistakes - Help and Advice
1.10 Key Takeaways
1.11 Checklist: Before Moving On
1.12 Key Functions & Commands
1.13 💡 Reproducibility Tip:
2 Introduction to tidyverse
2.1 Learning Objectives {tidyverse-objectives}
2.2 Using Packages
2.2.1 Installing Packages
2.2.2 Loading Packages
2.3 Meet the tidyverse
2.3.1 The Pipe
2.4 Manipulating Data in tidyverse
2.4.1 Distinct
2.4.2 Select
2.4.3 Filter
2.4.4 Arrange
2.4.5 Mutate
2.4.6 If Else
2.4.7 Renaming Columns
2.4.8 Putting them all together
2.5 Insights Into Our Data
2.5.1 Count
2.5.2 Summarizing and Grouping
2.6 Common Gotchas & Quick Fixes
2.6.1 = vs ==
2.6.2 NA-aware math
2.6.3 Pipe position
2.6.4 Conflicting function names
2.7 Key Takeaways
2.8 Checklist
2.9 Key Functions & Commands
2.10 💡 Reproducibility Tip:
3 Visualizations
3.1 Introduction
3.2 Learning Objectives
3.3 Base R
3.4 ggplot2
3.4.1 Basics
3.4.2 Scatterplot - geom_point()
3.4.3 Bar Chart (counts) and Column Chart (values)
3.4.4 Histograms and Density Plots (distribution)
3.4.5 Boxplot - geom_boxplot()
3.4.6 Lines (time series) - geom_line()
3.4.7 Put text on the plot - geom_text()
3.4.8 Error bars (requires summary stats) - geom_errorbar()
3.4.9 Reference lines
3.5 Key Takeaways
3.6 Checklist
3.7 ggplot2 Visualization Reference
3.7.1 Summary of ggplot Geometries
3.7.2 Summary of other ggplot commands
3.8 💡 Reproducibility Tip:
4 Comparing Two Groups: Data Wrangling, Visualization, and t-Tests
4.1 Introduction
4.2 Learning Objectives {means-objectives}
4.3 Creating a Sample Dataset
4.4 Merging Data
4.4.1 Binding our data
4.4.2 Joining Data
4.4.3 Wide Format
4.4.4 Long Format (Reverse Demo)
4.5 Comparing Means
4.5.1 Calculating the means
4.5.2 t.test
4.6 Key Takeaways
4.7 Checklist
4.7.1 Data Creation & Import
4.7.2 Comparing Two Means
4.8 Key Functions & Commands
4.9 Example APA-style Write-up
4.10 💡 Reproducibility Tip:
5 Comparing Multiple Means
5.1 Introduction
5.2 Learning Objectives {anova-objectives}
5.3 Creating Our Data
5.4 Descriptive Statistics
5.5 Visualizing Relationships
5.6 Running a T.Test
5.7 One-Way ANOVA
5.8 Post-hoc Tests
5.9 Adding a Second Factor
5.10 Model Comparison With AIC
5.11 Key Takeaways
5.12 Checklist
5.13 Key Functions & Commands
5.14 Example APA-style Write-up
5.15 💡 Reproducibility Tip:
6 Analyzing Categorical Data
6.1 Introduction
6.2 Learning Objectives {cat-objectives}
6.3 Loading Our Data
6.4 Contingency Tables
6.5 Visualizations
6.6 Chi-Square Test
6.7 Cross Tables
6.8 Contribution
6.9 CramerV
6.10 Interpretation
6.11 Key Takeaways
6.12 Checklist
6.13 Key Functions & Commands
6.14 Example APA-style Write-up
6.15 💡 Reproducibility Tip:
7 Correlation
7.1 Introduction
7.1.1 Learning Objectives
7.2 Loading Our Data
7.3 Cleaning our data
7.4 Visualizing Relationships
7.5 Running Correlations (r)
7.6 Correlation Matrix
7.7 Coefficient of Determination (R^2)
7.8 Partial Correlations
7.9 Biserial and Point-Biserial Correlations
7.10 Grouped Correlations
7.11 Conclusion
7.12 Key Takeaways
7.13 Checklist
7.14 Key Functions & Commands
7.15 Example APA-style Write-up
7.15.1 Bivariate Correlation
7.15.2 Positive Correlation
7.15.3 Partial Correlation
7.16 💡 Reproducibility Tip:
8 Linear Regression
8.1 Introduction
8.2 Learning Objectives {lin-reg-objectives}
8.3 Loading Our Data
8.4 Cleaning Our Data
8.5 Visualizing Relationships
8.6 Understanding Correlation
8.7 Linear Regression Model
8.8 Checking the residuals
8.9 Adding more variables
8.9.1 Bonus code
8.10 Conclusion
8.11 Key Takeaways
8.12 Checklist
8.13 Key Functions & Commands
8.14 Example APA-style Write-up
8.15 💡 Reproducibility Tip:
9 Logistic Regression
9.1 Introduction
9.2 Learning Objectives {log-reg-objectives}
9.3 Load and Preview Data
9.4 Exploratory Data Analysis
9.5 Visualize Relationships
9.6 Train and Test Split
9.7 Build Logistic Regression Model
9.7.1 McFadden’s Pseudo-R²
9.7.2 Variable Importance
9.7.3 Multicollinearity check
9.8 Make Predictions
9.9 Evaluate Model
9.10 ROC Curve + AUC
9.11 Interpretation
9.12 Key Takeaways
9.13 Checklist
9.14 Key Functions & Commands
9.15 Example APA-style Write-up
9.16 💡 Reproducibility Tip:
10 Reproducible Reporting
10.1 Introduction
10.2 Learning Objectives {r-markdown-objectives}
10.3 Creating an R Markdown File
10.4 Parts of an R Markdown File
10.4.1 The YAML
10.4.2 Text
10.4.3 R Chunks
10.4.4 Sections
10.5 Knitting an R Markdown File
10.6 Publishing an R Markdown file
10.7 Extras
10.7.1 Links
10.7.2 Pictures
10.7.3 Checklists
10.7.4 Standout sections
10.7.5 Changing Setting of Specific R Chunks
10.8 Key Takeaways
10.9 Checklist
10.10 Key Functions & Commands
10.11 Summary of Common R Markdown Syntax
10.12 💡 Reproducibility Tip:
Appendix: Reproducibility Checklist for Data Analysis in R
10.13 Project & Environment
10.14 Data Integrity & Structure
10.15 Data Transformation & Workflow
10.16 Merging & Reshaping Data
10.17 Visualization & Communication
10.18 Statistical Reasoning
10.19 Modeling & Inference
10.20 Randomness & Evaluation
10.21 Reporting & Execution
10.22 Final Check
Packages & Functions Reference
About This Text
Reproducible Research In R
Christian Martinez
2026-01-05
Annotate
Close
Next Chapter
About
Next
Textbook