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:

convMeters <- function(val, to="inch")
  {mult<- switch(to, inch=39.3701,foot=3.28084,yard=1.09361,mile=0.000621371, centimeters=100, NA) 
  if (is.na(mult)) print("Unkown target unit of length.") else return(val*mult)
}
convMeters(23,"foot")
## [1] 75.45932
Inches= convMeters(40,"inch")
sprintf("40 meters are equivalent to %f inches", Inches)
## [1] "40 meters are equivalent to 1574.804000 inches"
convMeters(40)
## [1] 1574.804
convMeters(2.4,"km")
## [1] "Unkown target unit of length."

Including Plots

You can also embed plots, for example:

x <- rnorm(50)
x
##  [1]  1.23396939  0.75130881  0.73391766  0.15390852 -1.19970591  0.52737124
##  [7] -1.35945810  0.12597511  0.07489895  0.33958463 -1.26194708 -1.24047004
## [13]  1.02892565 -0.88293183 -0.30965730 -2.38101453  0.11064273 -0.30225212
## [19] -0.91786028  3.12333851 -0.91774214  0.49253467 -0.49247046 -0.42705042
## [25]  1.99388243  0.80886410  0.68997627 -1.90525130  0.59915490  0.61807269
## [31]  0.65220071  1.88228427  0.65896394 -1.08207241 -0.68154409  1.34034828
## [37]  1.35410502  0.75760428 -0.03102831  0.61149874  1.64968946  1.42449598
## [43]  0.30607359  0.22376744 -0.23973948  0.63089738  0.55635060  0.37963787
## [49] -0.34720532 -0.64455491
y= mean(x)
y
## [1] 0.1842058
x2<-rnorm(50, mean=50, sd=.1)
x2
##  [1] 50.17227 49.93074 49.95128 49.85340 50.17667 49.99729 49.99623 49.94257
##  [9] 49.87618 49.95687 50.36321 49.87190 49.99063 49.98636 49.78786 49.97701
## [17] 50.02662 49.95043 50.09329 49.90678 49.89793 49.88497 49.97322 49.68438
## [25] 50.15908 49.96884 50.04188 50.00188 50.02702 49.88840 50.05506 49.88479
## [33] 49.88483 50.04546 50.02048 49.88008 49.86346 50.27758 49.97978 50.16062
## [41] 49.89654 50.07112 50.15412 49.94044 50.06098 50.12283 49.89451 50.16971
## [49] 50.22343 49.98013
years <- c(1980, 1985, 1990)
scores <- c(34, 44, 83)
df <- data.frame(years, scores)
df[,1]
## [1] 1980 1985 1990
df$years
## [1] 1980 1985 1990
df$scores
## [1] 34 44 83
View(df)

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.