Setting Enviroment

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:

install.packages("benchmarkme") 
## package 'benchmarkme' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\MAVOURIN\AppData\Local\Temp\Rtmp0Q7YfU\downloaded_packages
library(benchmarkme)
Sys.info()
##           sysname           release           version          nodename 
##         "Windows"          "10 x64"     "build 22631" "DESKTOP-F35CUEV" 
##           machine             login              user    effective_user 
##          "x86-64"        "MAVOURIN"        "MAVOURIN"        "MAVOURIN"

Translated into English, the above output means that R is running on a 64 bit Windows version 22631 and that the current user is xling.

install.packages("car") 
## Installing package into 'C:/Users/MAVOURIN/AppData/Local/R/win-library/4.4'
## (as 'lib' is unspecified)
## package 'car' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\MAVOURIN\AppData\Local\Temp\Rtmp0Q7YfU\downloaded_packages
library(car)
## Loading required package: carData

minimum value of mpg

min(mtcars$mpg) 
## [1] 10.4
attach(mtcars)
min(mpg)
## [1] 10.4
max(mpg)  
## [1] 33.9
median(mpg) 
## [1] 19.2
sd(mpg)  
## [1] 6.026948
var(mpg)  
## [1] 36.3241
quantile(mpg, 0.25)
##    25% 
## 15.425
quantile(mpg, 0.50)
##  50% 
## 19.2
quantile(mpg, 0.75)
##  75% 
## 22.8
quantile(mpg, 1)
## 100% 
## 33.9
quantile(mpg,c(0.25,0.5,0.75,1))
##    25%    50%    75%   100% 
## 15.425 19.200 22.800 33.900

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Including Plots

You can also embed plots, for example:

regular plot

fancy plot

install.packages("ggplot2")
## package 'ggplot2' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\MAVOURIN\AppData\Local\Temp\Rtmp0Q7YfU\downloaded_packages
library(ggplot2)
ggplot(data=mtcars,aes(x=wt, y=mpg)) + geom_point() + stat_smooth(method="lm", se=FALSE)