Course: GRE English Vocabulary
Getting Started! Welcome to the "Getting Started!" chapter of our data analysis course. This chapter guides learners through installing R and RStudio, introduces basic R syntax for variables and arithmetic, and shows how to import common data formats such as CSV. You will learn essential data exploration functions like str(), summary(), and head() to quickly understand dataset structure and summary statistics. The chapter emphasizes data visualization with ggplot2, including examples of scatter plots and regression lines to reveal patterns and relationships. We also introduce basic statistical modeling using lm() to fit simple linear regressions and demonstrate how to generate and visualize predictions. Practical package recommendations—dplyr for manipulation, tidyr for reshaping, and lubridate for date handling—are provided to streamline workflows. Alongside technical examples, the chapter includes vocabulary building and applied exercises (True/False, MCQ, matching) to consolidate understanding. There is an applied mini‑project showing how to analyze GRE practice test scores in R, compute means, and chart progress with ggplot2. Emphasis is placed on reproducibility: setting seeds for sampling, annotating code, and saving outputs for review. Importantly, learners are encouraged to practice regularly, explore variations of examples, and inspect model diagnostics such as residuals and confidence intervals. By completing this chapter, students will have a practical foundation to import, explore, visualize, and model data in R and be prepared to tackle more advanced data cleaning and analysis tasks.Lesson
Subtitle: Getting Started — Introduction to R and Data Analysis
Learning Outcomes
| Outcome | Success Criteria |
|---|---|
| Install and configure R & RStudio |
AnswerR and RStudio are installed from CRAN and RStudio's website; RStudio opens with Console, Source, Environment panes. Confirm by running print("Hello, World!"). |
| Write basic R syntax |
AnswerCreate variables with <-, perform arithmetic, and use print() to display values; e.g., x <- 5; y <- 10; print(x+y). |
| Import and explore tabular data |
AnswerUse read.csv("path/to/file.csv"), then str(data), summary(data), head(data) to inspect structure and basic statistics. |
| Visualize data with ggplot2 |
AnswerInstall ggplot2, then use ggplot(data, aes(x=Var1, y=Var2)) + geom_point() and add geom_smooth(method="lm") for trend lines. |
| Fit a simple statistical model |
AnswerFit linear models using lm(response ~ predictor, data = data); review summary(model), extract residuals and predictions with predict(). |
Conceptual Explanation
R is a language and environment tailored for statistics and graphics. At the core of data analysis are steps: (1) obtain data, (2) explore and clean it, (3) visualize patterns, and (4) model relationships to make inferences or predictions. Packages extend base R: dplyr for data manipulation, tidyr for reshaping, ggplot2 for layered graphics, and lubridate for dates. A typical workflow starts with read.csv(), proceeds through str() and summary(), then uses ggplot2 visual checks before fitting models with lm(). Model diagnostics such as residual plots and confidence intervals are essential to assess validity. Reproducibility is enforced by commenting code, using set.seed() for sampling, and saving scripts/projects in RStudio.
Bilingual (EN → বাংলা)
| English | বাংলা (Bangla) |
|---|---|
| Install R and RStudio |
AnswerR ও RStudio ইনস্টল করুন (CRAN এবং RStudio ওয়েবসাইট থেকে)। RStudio খুললে Console, Source ও Environment প্যান দেখবেন। |
| Read CSV data |
AnswerCSV ফাইল পড়তে read.csv("path/to/file.csv") ব্যবহার করুন এবং head(), str(), summary() দিয়ে ডেটা পর্যালোচনা করুন। |
| Plot with ggplot2 |
Answerggplot2 দিয়ে scatter plot তৈরি করতে ggplot(data, aes(x, y)) + geom_point() ব্যবহার করুন; regression লাইনের জন্য geom_smooth(method="lm") যোগ করুন। |
Important Notes
-
Answer
Always check variable types (numeric, factor, character). Use str() and as.factor()/as.numeric() to convert types as needed. -
Answer
For reproducible sampling use set.seed(123) before sample() to make results repeatable. -
Answer
When installing packages, run install.packages("pkg") once, then library(pkg) each session; prefer tidyverse packages for streamlined workflows. -
Answer
Inspect model residuals (plot(model) or hist(model$residuals)) to detect nonlinearity, heteroscedasticity, or outliers.
Exercises → True / False / Fill in the Blanks / MCQ / Matching / Descriptive / Creative
True / False
| # | Statement | Answer |
|---|---|---|
| 1 | ggplot2 is a base R plotting function. |
AnswerFalse — ggplot2 is an external package (part of the tidyverse), not a base plotting function. |
| 2 | read.csv() automatically converts strings to factors by default in recent R versions. |
AnswerFalse — since R 4.0.0 stringsAsFactors default is FALSE; explicit conversion to factor is recommended when needed. |
| 3 | Setting a random seed ensures the same sample across runs (given same code and data). |
AnswerTrue — set.seed() makes random operations reproducible within the same R version/environment. |
Fill in the Blanks
| # | Prompt | Answer |
|---|---|---|
| 1 | Use ________ to import a CSV file into R. |
Answerread.csv() |
| 2 | Use ________ from ggplot2 to add a linear regression smoothing line. |
Answergeom_smooth(method = "lm") |
| 3 | The function ________ shows the structure and types of columns in a data frame. |
Answerstr() |
Multiple Choice (MCQ)
| # | Question | Choices | Answer |
|---|---|---|---|
| 1 | Which function fits a linear model in R? | A) lm() B) glmplot() C) summarize() D) fitlm() |
AnswerA) lm() |
| 2 | Which package is most associated with data manipulation verbs like filter and mutate? | A) ggplot2 B) dplyr C) readr D) lubridate |
AnswerB) dplyr |
| 3 | Which function shows the first six rows of a data frame? | A) tail() B) head() C) top() D) show() |
AnswerB) head() |
Matching
| Left | Match → Right | Answer |
|---|---|---|
| A. ggplot2 | 1. Data manipulation |
AnswerA → 3 (Data visualization). Full mapping: A:3, B:1, C:4, D:2. |
| B. dplyr | 2. Time handling |
AnswerB → 1 (Data manipulation) |
| C. tidyr | 3. Visualization |
AnswerC → 4 (Reshaping/tidying data) |
| D. lubridate | 4. Reshaping |
AnswerD → 2 (Time handling) |
Descriptive
-
Explain the steps you would take to prepare a CSV dataset for a linear regression in R.
Answer
Steps: (1) read.csv("file.csv") to import; (2) use str() and summary() to check types and missing values; (3) convert categorical variables to factors; (4) handle missing data (na.omit or imputation); (5) create train/test split or cross-validation; (6) fit lm(y ~ x1 + x2, data = train); (7) check diagnostics (residuals, R-squared, p-values); (8) predict on test set and evaluate metrics (RMSE, MAE). -
Describe how you would visualize and detect outliers in a numeric variable.
Answer
Use boxplot(var) to view whiskers and potential outliers, histogram(var) to examine distribution, and compute IQR with Q1/Q3 to identify values outside [Q1 - 1.5*IQR, Q3 + 1.5*IQR]. Also consider z-scores and scatter plots against related variables to see context.
Creative
Project: Analyze a small practice dataset (e.g., GRE practice scores) and produce a one‑page report with a plot and a short interpretation.
Answer
Suggested deliverables: (1) a data frame with Test_Number and Score; (2) compute mean and sd; (3) plot scores over time with ggplot (geom_line + geom_point); (4) fit lm(Score ~ Test_Number) to detect trend and report coefficient and p-value; (5) write a 150–200 word interpretation describing trend, variability, and recommendation for further practice.Activities, Vocabulary, Homework, Practice Task
Activities
-
Activity A: Install R & RStudio and run a Hello World script.
Answer
After installation, open RStudio and run print("Hello, World!") in the console. Capture a screenshot and note sessionInfo(). -
Activity B: Import a CSV and create a scatter plot of two numeric columns.
Answer
Use data <- read.csv("your.csv"), then ggplot(data, aes(x=col1, y=col2)) + geom_point() + theme_minimal().
Vocabulary
| Term | Short Definition | Example |
|---|---|---|
| Data Frame | Table-like structure with columns of possibly different types. |
Answermy_data <- data.frame(Name=c("A","B"), Score=c(85,90)) |
| Vector | One-dimensional homogeneous container. |
Answerv <- c(1,2,3) |
| Residuals | Observed minus predicted values from a model. |
Answerresiduals <- model$residuals; hist(residuals) |
Homework
-
Homework 1: Recreate the GRE scores example with at least 5 simulated test scores and produce a plot plus mean calculation.
Answer
Use scores <- data.frame(Test_Number=1:5, Score=c(150,152,155,157,160)); mean(scores$Score); ggplot... -
Homework 2: Prepare a one‑page glossary of 10 vocabulary terms from this lesson with definitions and one-line R examples for each.
Answer
Choose terms like data frame, vector, factor, ggplot2, lm, correlation, outlier, IQR, residuals, confidence interval.
Practice Task
Task: Given a CSV with columns Age and Score, compute correlation, fit lm(Score ~ Age), and save a PNG showing scatter with regression line.
Answer
Example code:# Read data
data <- read.csv("data.csv")
# Correlation
cor(data$Age, data$Score)
# Model
model <- lm(Score ~ Age, data = data)
summary(model)
# Plot and save
library(ggplot2)
p <- ggplot(data, aes(x = Age, y = Score)) + geom_point() + geom_smooth(method = "lm") + theme_minimal()
ggsave("age_score_plot.png", plot = p, width = 6, height = 4)