Thetazero Pubs
woodiel14

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:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

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.

babies2<-subset(babies[,c(1,7,12,13)], wt<999&ht<99&wt.1<999)


website<-'http://www.stat.berkeley.edu/~statlabs/data/babies23.data'
download.file(website,destfile<-'babies', method<-'auto')
babies<-read.table(website)
babies2<-subset(babies[1:59,c(1,7,12,13)])
names(babies2)<-c('id', 'baby.weight', 'mother.height', 'mother.weight')
babies2$mother.height <-as.numeric(as.character(babies2$mother.height)) * 0.0254
## Warning: NAs introduced by coercion
babies2$mother.weight <-as.numeric(as.character(babies2$mother.weight)) * 0.453592
## Warning: NAs introduced by coercion
babies2$mother.bmi <- babies2$mother.weight/(babies2$mother.height)^2
ind<-babies2$mother.bmi>=30
babies2$mother.bmi[ind]
## [1]        NA  32.55627 166.24046  30.23140  31.35380  71.66268
ord<-order(babies2$mother.bmi, decreasing=TRUE)
babies2$mother.bmi[ord][1:10]
##  [1] 166.24046  71.66268  32.55627  31.35380  30.23140  29.12120  28.05778
##  [8]  27.67270  27.58615  27.40857

babies2$mother.bmi<-(c(mother.weight))/((c(mother.height)^2))

Copyright © 2016 thetazero.com All Rights Reserved. Privacy Policy