Use R to display the file path to the work directory?
From getwd(), I got R to display the file path to the work directory as: “/Users/tiffamee/Desktop/FALL 2017/CLASSES/PH 251D/Homework Chapter 2/ph251d-homework”.
Recreate Table 2.26 using any combination of the matrix, cbind, rbind, dimnames, or names functions.
table2.26 <- matrix(c(139, 443, 230, 502), 2,2) #creating the matrix rownames(table2.26) <- c(“Dead”, “Alive”) #naming the rows colnames(table2.26) <- c(“Yes”, “No”) #naming the columns names(dimnames(table2.26)) <- c(“Vital Status”, “Smoking”) table2.26
library(knitr)
table2.26 <- matrix(c(139, 443, 230, 502), 2,2)
rownames(table2.26) <- c("Dead", "Alive")
colnames(table2.26) <- c("Yes", "No")
names(dimnames(table2.26)) <- c("Vital Status", "Smoking")
kable(table2.26, caption = "Recreating Table 2.26")
| Yes | No | |
|---|---|---|
| Dead | 139 | 230 |
| Alive | 443 | 502 |