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:
sum <- 1
for(i in 12:1) {
sum = sum * (i)
print(sum)
next
}
## [1] 12
## [1] 132
## [1] 1320
## [1] 11880
## [1] 95040
## [1] 665280
## [1] 3991680
## [1] 19958400
## [1] 79833600
## [1] 239500800
## [1] 479001600
## [1] 479001600
vec <- seq(20,50,by=5)
typeof(vec)
## [1] "double"
vec
## [1] 20 25 30 35 40 45 50
factorial <- function (a,b,c)
{
sq = sqrt((b*b)-(4*a*c))
sol1 = ((-1*b)+sq)/(2*a)
sol2 = ((-1*b)-sq)/(2*a)
answer = paste("The Solutions are ",sol1,",",sol2)
return(answer)
}
factorial(1,4,3)
## [1] "The Solutions are -1 , -3"
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.