Different R Markdown Features

Author

F. Heiss

Header 1: Hiding Input and/or Output

We can run R code but hide

  • the input with echo=FALSE and/or
  • the results with include=FALSE

Header 2: Usual R Output

By default, both input commands and R output are displayed:

table(gpa1$age)

19 20 21 22 23 25 26 30 
 7 48 56 26  1  1  1  1 
olsres <- lm(colGPA ~ hsGPA, data=gpa1)
stargazer(olsres,type="text")

===============================================
                        Dependent variable:    
                    ---------------------------
                              colGPA           
-----------------------------------------------
hsGPA                        0.482***          
                              (0.090)          
                                               
Constant                     1.415***          
                              (0.307)          
                                               
-----------------------------------------------
Observations                    141            
R2                             0.172           
Adjusted R2                    0.166           
Residual Std. Error      0.340 (df = 139)      
F Statistic           28.845*** (df = 1; 139)  
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01

Header 3: Formulas and inline R results

We can also include formulas using LaTeX syntax if we have LaTeX installed. \[\overline x = \sum_{i=1}^n x_i\]

And we can use R results inside of the text like in \(\hat\beta_1=\) 0.4824346.