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:

convTemp <- function(val, to="kelvin"){
  mult <- switch(to, kelvin = val+273.15, celsius = val-273.15, fahrenheit = (val-273.15)*1.8 + 32, NA)
  if (is.na(mult)) stop("Unknown target")else return(mult)
}

Celsius <- convTemp(100, "celsius")
sprintf("100 degrees kelvin is %f degrees celsius", Celsius)
## [1] "100 degrees kelvin is -173.150000 degrees celsius"
Fahrenheit <- convTemp(10, "fahrenheit")
sprintf("10 degrees kelvin is %f  fahrenheit", Fahrenheit)
## [1] "10 degrees kelvin is -441.670000  fahrenheit"
Kelvin <- convTemp(20)
sprintf("20 degrees celsius is %f kelvin", Kelvin)
## [1] "20 degrees celsius is 293.150000 kelvin"

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.