`
```r
se<-function(x){
v<- var(x)
n<- length(x)
return(sqrt(v/n))
}
mySample<-rnorm(100, mean=20,sd=4)
se(mySample)
## [1] 0.420738
convert<-function(x){
degree<- (x - 32) / (9/5)
return(degree)
}
vector<-c(12, 67, 78,100)
convert(vector)
## [1] -11.11111 19.44444 25.55556 37.77778
x<- rnorm(100)
y<- rnorm(100)
plot(x,y)
g<-c("f","f","m","f","m","f","m","m")
sex<-factor(g,levels = c("f","m"))
g
## [1] "f" "f" "m" "f" "m" "f" "m" "m"
sex
## [1] f f m f m f m m
## Levels: f m
t<-table(sex,g)
years<-c(1980, 1980, 1985, 1990)
scores<-c(34, 44, 56, 83)
subject_name<-c("John Doe", "Jane Doe", "Steve Graves")
temperature<-c(98.1, 98.6, 101.4)
flu_status<-c(FALSE, FALSE, TRUE)
gender<-factor(c("MALE", "FEMALE", "MALE"))
blood<-factor(c("O", "AB", "A"), levels = c("A", "B", "AB", "O"))
symptoms<- factor(c("SEVERE", "MILD", "MODERATE"), levels = c("MILD", "MODERATE", "SEVERE"), ordered = TRUE)
symptoms > "MODERATE"
## [1] TRUE FALSE FALSE
pt_data<-data.frame(subject_name, temperature, flu_status, gender, blood, symptoms, stringsAsFactors = FALSE)
pt_data[c(1,3), c("temperature", "gender")]
## temperature gender
## 1 98.1 MALE
## 3 101.4 MALE
pt_data$temp_c<-(pt_data$temperature-32) * (5/9)
pt_data
## subject_name temperature flu_status gender blood symptoms temp_c
## 1 John Doe 98.1 FALSE MALE O SEVERE 36.72222
## 2 Jane Doe 98.6 FALSE FEMALE AB MILD 37.00000
## 3 Steve Graves 101.4 TRUE MALE A MODERATE 38.55556
library(ggplot2)
ggplot(data = mpg) + geom_smooth(mapping=aes(x=displ,y=hwy,linetype=drv))
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
ggplot(data = mpg) + geom_smooth(mapping=aes(x=displ, y=hwy))
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
ggplot(data = mpg) + geom_smooth(mapping=aes(x=displ, y=hwy, group=drv))
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
ggplot(data = mpg) + geom_smooth(mapping=aes(x=displ, y=hwy, color=drv), show.legend = FALSE)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
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:
## Including Plots
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.