R Markdown

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:

df<-read.csv("https://archive.ics.uci.edu/ml/machine-learning-databases/bridges/bridges.data.version2", stringsAsFactors = TRUE)

dim(df)
## [1] 107  13
head(df)
##   E1 M X3 CRAFTS  HIGHWAY     X. X2 N THROUGH WOOD  SHORT S WOOD.1
## 1 E2 A 25 CRAFTS  HIGHWAY MEDIUM  2 N THROUGH WOOD  SHORT S   WOOD
## 2 E3 A 39 CRAFTS AQUEDUCT      ?  1 N THROUGH WOOD      ? S   WOOD
## 3 E5 A 29 CRAFTS  HIGHWAY MEDIUM  2 N THROUGH WOOD  SHORT S   WOOD
## 4 E6 M 23 CRAFTS  HIGHWAY      ?  2 N THROUGH WOOD      ? S   WOOD
## 5 E7 A 27 CRAFTS  HIGHWAY  SHORT  2 N THROUGH WOOD MEDIUM S   WOOD
## 6 E8 A 28 CRAFTS AQUEDUCT MEDIUM  1 N THROUGH IRON  SHORT S SUSPEN
bridges_new<-df[, 2:5] 

colnames(bridges_new)<- c("RIVER", "LOCATION", "ERECTED", "USE")
head(bridges_new)
##   RIVER LOCATION ERECTED      USE
## 1     A       25  CRAFTS  HIGHWAY
## 2     A       39  CRAFTS AQUEDUCT
## 3     A       29  CRAFTS  HIGHWAY
## 4     M       23  CRAFTS  HIGHWAY
## 5     A       27  CRAFTS  HIGHWAY
## 6     A       28  CRAFTS AQUEDUCT
bridgestab<- round(prop.table(table(bridges_new$USE, bridges_new$RIVER)),2)
bridgestab
##           
##               A    M    O    Y
##   AQUEDUCT 0.04 0.00 0.00 0.00
##   HIGHWAY  0.30 0.23 0.10 0.02
##   RR       0.11 0.14 0.04 0.01
##   WALK     0.01 0.00 0.00 0.00

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.