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:
years <- c(1980, 1990, 1985, 1990)
scores <- c(34, 44, 56, 83)
initial <- c('d', 'b', 's', 'u')
df <- data.frame(years, scores, initial)
df
## years scores initial
## 1 1980 34 d
## 2 1990 44 b
## 3 1985 56 s
## 4 1990 83 u
#Patient index
subject_name <- c("John Doe", "Jane Doe", "Steve Graves", "Jack Smith", "Ashley Johnson")
gender <- factor(c("MALE", "FEMALE", "MALE", "MALE", "FEMALE"))
blood <- factor(c("O", "AB", "A", "O", "AB"), levels = c("A", "B", "AB", "O"))
temperature <- c(98.1, 98.6, 101.4, 98.3, 102.1)
flu_status <- c(FALSE, FALSE, TRUE, FALSE, TRUE)
symptoms <- factor(c("SEVERE", "MILD", "MODERATE", "MILD", "SEVERE"), levels = c("MILD", "MODERATE", "SEVERE"), ordered = TRUE)
dfr <- data.frame(subject_name, gender, blood, temperature, flu_status)
dfr
## subject_name gender blood temperature flu_status
## 1 John Doe MALE O 98.1 FALSE
## 2 Jane Doe FEMALE AB 98.6 FALSE
## 3 Steve Graves MALE A 101.4 TRUE
## 4 Jack Smith MALE O 98.3 FALSE
## 5 Ashley Johnson FEMALE AB 102.1 TRUE
pt_data <- data.frame(subject_name, gender, blood, temperature, flu_status, symptoms, stringsAsFactors = FALSE)
pt_data$temp_c <- (pt_data$temperature - 32)* (5/9)
pt_data
## subject_name gender blood temperature flu_status symptoms temp_c
## 1 John Doe MALE O 98.1 FALSE SEVERE 36.72222
## 2 Jane Doe FEMALE AB 98.6 FALSE MILD 37.00000
## 3 Steve Graves MALE A 101.4 TRUE MODERATE 38.55556
## 4 Jack Smith MALE O 98.3 FALSE MILD 36.83333
## 5 Ashley Johnson FEMALE AB 102.1 TRUE SEVERE 38.94444
library(ggplot2)
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy))
#displacement/city milage
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = cty))
#displacement/cylinders
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = cyl))
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, color = class))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), color = "blue")
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy)) + facet_wrap(~class, nrow = 2)
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy)) + facet_wrap(~cyl, nrow = 3)
ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy)) + facet_grid(drv ~ cyl)