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:

Exercise 4

a function to converts US dollars to Euros.

us2eur <- function(x, xr)
  return(paste(format(round(x*100/xr, 0)/100, nsmall=2),
         sep=""))

set the exchange rate

xr <- 1.11664

pick some random amount of money

x <- round(rnorm(10, mean=200, sd=50))

show conversion

data.frame(USD=x, EUR=us2eur(x, xr))
   USD    EUR
1  206 184.48
2  244 218.51
3  205 183.59
4  144 128.96
5  165 147.76
6  247 221.20
7   80  71.64
8  271 242.69
9  109  97.61
10 229 205.08