This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
"C2"
## [1] "C2"
'1'
## [1] "1"
library(wooldridge)
num_women <- nrow(bwght)
num_smokers <- sum(bwght$smoke == 1, na.rm = TRUE)
num_women
## [1] 1388
num_smokers
## [1] 0
'2'
## [1] "2"
avg_cigs <- mean(bwght$cigs, na.rm = TRUE)
avg_cigs
## [1] 2.087176
median_cigs <- median(bwght$cigs, na.rm = TRUE)
avg_cigs
## [1] 2.087176
median_cigs
## [1] 0
'3'
## [1] "3"
smokers_data <- subset(bwght, smoke == 1)
avg_cigs_smokers <- mean(smokers_data$cigs, na.rm = TRUE)
avg_cigs_smokers
## [1] NaN
'4'
## [1] "4"
avg_fatheduc <- mean(bwght$fatheduc, na.rm = TRUE)
valid_obs_fatheduc <- sum(!is.na(bwght$fatheduc))
avg_fatheduc
## [1] 13.18624
valid_obs_fatheduc
## [1] 1192
'5'
## [1] "5"
avg_faminc <- mean(bwght$faminc, na.rm = TRUE)
sd_faminc <- sd(bwght$faminc, na.rm = TRUE)
avg_faminc
## [1] 29.02666
sd_faminc
## [1] 18.73928
"C3"
## [1] "C3"
'1'
## [1] "1"
max_math4 <- max(meap01$math4, na.rm = TRUE)
min_math4 <- min(meap01$math4, na.rm = TRUE)
max_math4
## [1] 100
min_math4
## [1] 0
'2'
## [1] "2"
num_perfect_pass <- sum(meap01$math4 == 100, na.rm = TRUE)
percentage_perfect_pass <- (num_perfect_pass / nrow(meap01)) * 100
num_perfect_pass
## [1] 38
percentage_perfect_pass
## [1] 2.084476
'3'
## [1] "3"
num_50_percent_pass <- sum(meap01$math4 == 50, na.rm = TRUE)
num_50_percent_pass
## [1] 17
'4'
## [1] "4"
avg_math_pass <- mean(meap01$math4, na.rm = TRUE)
avg_read_pass <- mean(meap01$read4, na.rm = TRUE)
avg_math_pass
## [1] 71.909
avg_read_pass
## [1] 60.06188
'5'
## [1] "5"
correlation <- cor(meap01$math4, meap01$read4, use = "complete.obs")
correlation
## [1] 0.8427281
'6'
## [1] "6"
avg_exppp <- mean(meap01$exppp, na.rm = TRUE)
sd_exppp <- sd(meap01$exppp, na.rm = TRUE)
avg_exppp
## [1] 5194.865
sd_exppp
## [1] 1091.89
'7'
## [1] "7"
school_A <- 6000
school_B <- 5500
percent_diff <- ((school_A - school_B) / school_B) * 100
log_diff <- 100 * (log(school_A) - log(school_B))
percent_diff
## [1] 9.090909
log_diff
## [1] 8.701138
You can also embed plots, for example:
Note that the echo = FALSE
parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.