This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---Question 5: | |
# Set a seed for reproducibility of the random data. | |
set.seed(42) | |
# Define the number of observations. | |
n <- 2000 | |
# Create the primary predictor variable X1 (years of education) from a normal distribution. | |
X1 <- rnorm(n, mean = 0, sd = 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1. Data Exploration | |
# install.packages("medicaldata") | |
library(medicaldata) | |
library(ggplot2) | |
data(laryngoscope) | |
?laryngoscope #check the documentation of the dataset | |
dim(laryngoscope) #check the dimensions of the dataset | |
#2. Data Analysis | |
nrow(laryngoscope[laryngoscope$gender == 0, ]) #calculate the number of female patients |