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:
input<-12
fact <- 1
for(i in 1:input) {
fact = fact * i
}
print(fact)
## [1] 479001600
sequence of numbers from 20:50 and the output divided by 5
vec <- seq(20, 50, 5)
as.numeric(vec)
## [1] 20 25 30 35 40 45 50
create a “Quadratic”function. ax^2 + bx + c
quadratic <- function(a,b,c) {
root <- (b^2) - (4*a*c)
x_pos <- (-b + sqrt(root)) / (2*a)
x_neg <- (-b - sqrt(root)) / (2*a)
return (paste0( "the two x-intercept for the quadratic equation are: " , x_pos , " and " , x_neg))
}
quadratic(1,7,5)
## [1] "the two x-intercept for the quadratic equation are: -0.807417596432748 and -6.19258240356725"
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.