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:

4+ 3/5^2
## [1] 4.12
set.seed(7)
x<-rnorm(4,mean= 10)
x
## [1] 12.287247  8.803228  9.305707  9.587707
s1<-sample(1:10,5)
s1
## [1]  6  8  9  3 10
sample(1:10,5, replace=TRUE)
## [1]  8 10  3  4  8
mean(sample(1:10,5))
## [1] 5.6
plot(x=sample(1:10,5), y=sample(1:10,5), main="Five random points", xlab="X values",ylab="Y values")

z <- 5
w <- z^2
w
## [1] 25
i <- (z * 2 + 45)/2
i
## [1] 27.5
rm(z,w,i,s1)
z <- 5
w <- z^2
w
## [1] 25
max(4,5,6,12,-4)
## [1] 12
max(sample(1:100,30))
## [1] 100
exists("se")
## [1] FALSE
exists("mean")
## [1] TRUE

Including Plots

se<-function(x){
  v<-var(x)
  n<-length(x)
  se<-sqrt(v/n)
  return (se)
}
se(c(1,2,3,4,5))
## [1] 0.7071068
f <- function(x){
  for(i in 1:10){
    res <- x*i
    cat(x, '*',i,'=',res,'\n')
  }
}
f(4)
## 4 * 1 = 4 
## 4 * 2 = 8 
## 4 * 3 = 12 
## 4 * 4 = 16 
## 4 * 5 = 20 
## 4 * 6 = 24 
## 4 * 7 = 28 
## 4 * 8 = 32 
## 4 * 9 = 36 
## 4 * 10 = 40

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.