This is my first R markdown file
Here, we are going to load some data
library(datasets)
data(airquality)
summary(airquality)
## Ozone Solar.R Wind Temp
## Min. : 1.00 Min. : 7.0 Min. : 1.700 Min. :56.00
## 1st Qu.: 18.00 1st Qu.:115.8 1st Qu.: 7.400 1st Qu.:72.00
## Median : 31.50 Median :205.0 Median : 9.700 Median :79.00
## Mean : 42.13 Mean :185.9 Mean : 9.958 Mean :77.88
## 3rd Qu.: 63.25 3rd Qu.:258.8 3rd Qu.:11.500 3rd Qu.:85.00
## Max. :168.00 Max. :334.0 Max. :20.700 Max. :97.00
## NA's :37 NA's :7
## Month Day
## Min. :5.000 Min. : 1.0
## 1st Qu.:6.000 1st Qu.: 8.0
## Median :7.000 Median :16.0
## Mean :6.993 Mean :15.8
## 3rd Qu.:8.000 3rd Qu.:23.0
## Max. :9.000 Max. :31.0
##
You can name your code chunks. If you don’t want to show code, but only a result of your command, use echo argument and set it to FALSE.
You can also hide results, although it makes no sence. Add to the code chunk argument results=“hide” and it will work.
pairs(airquality)
Here’s a regression model of ozon on wind, solar radiation, and temperature
library(stats)
library(pander)
fit <- lm(Ozone~Wind + Solar.R + Temp, data=airquality)
pander(fit, type = "html")
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| Wind | -3.334 | 0.6544 | -5.094 | 1.516e-06 |
| Solar.R | 0.05982 | 0.02319 | 2.58 | 0.01124 |
| Temp | 1.652 | 0.2535 | 6.516 | 2.424e-09 |
| (Intercept) | -64.34 | 23.05 | -2.791 | 0.006227 |
With some code chunks, we may not want the output generated by the chunk to be rendered into HTML but would prefer to print the output verbatim. How can we specify this preference for a given code chunk? Here is a nice table of regression coefficients. WHICH IS NOT NICE AT ALL SO THEREFORE I DECIDED TO HIDE IT.
Next, for example, you want to include some plot to the file. Let’s first of all simulate some data.
x<- rnorm(100); y <- x + rnorm (100, sd=0.5)
Here is a scatterplot to this data.
par(mar = c(5,4,1,1), las=1)
plot(x, y, main = "My Simulated Data")
Par function is used to set the margins and canvas. The option that I added here (fig.height = 4) adjusts the figure height a little bit.
We can also add formulas and calculations to the text inserting r code to the main body of the text. For example, the mean of our x variable in the dataset generated above accouns for 0.1540505.
That’s the way you can list your items.
item 1
item 2
item 3
You write it adding “##”" at the begining of the line. One # applies to the first header, and ### - to the tertiary header.
More detail on codes you can find on the R Markdown page.