Rmarkdown does not show outputs

Hi. I am brand new to R and I am trying to explore R studio. I have an issue with R markdown and I do not how to solve it. I am trying to run the rmarkdown template , but when I knit a file the output of the "summary(cars)" and the plot do not show up. I would be grateful if you could help.

---
title: "Alexis"
author: "Alexis Karamanos"
date: "18/01/2022"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## 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:

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

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

My session info is;

R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] dotwhisker_0.7.4  broom_0.7.11      miceadds_3.11-6   vcov_0.0.1        broom.mixed_0.2.7
 [6] lme4_1.1-27.1     Matrix_1.3-4      VIM_6.1.1         colorspace_2.0-2  mice_3.14.0      
[11] finalfit_1.0.4    sjlabelled_1.1.8  haven_2.4.3       forcats_0.5.1     stringr_1.4.0    
[16] dplyr_1.0.7       purrr_0.3.4       readr_2.1.1       tidyr_1.1.4       tibble_3.1.6     
[21] ggplot2_3.3.5     tidyverse_1.3.1   plm_2.4-3        

loaded via a namespace (and not attached):
 [1] minqa_1.2.4       ellipsis_0.3.2    class_7.3-19      estimability_1.3  ggstance_0.3.5   
 [6] parameters_0.16.0 fs_1.5.2          rstudioapi_0.13   proxy_0.4-26      farver_2.1.0     
[11] fansi_0.5.0       mvtnorm_1.1-3     lubridate_1.8.0   ranger_0.13.1     xml2_1.3.3       
[16] splines_4.1.1     robustbase_0.93-9 knitr_1.37        Formula_1.2-4     jsonlite_1.7.2   
[21] nloptr_1.2.2.3    dbplyr_2.1.1      compiler_4.1.1    httr_1.4.2        emmeans_1.7.2    
[26] backports_1.4.1   assertthat_0.2.1  fastmap_1.1.0     cli_3.1.0         htmltools_0.5.2  
[31] tools_4.1.1       coda_0.19-4       gtable_0.3.0      glue_1.6.0        Rcpp_1.0.7       
[36] carData_3.0-5     cellranger_1.1.0  vctrs_0.3.8       nlme_3.1-152      lmtest_0.9-39    
[41] insight_0.15.0    xfun_0.29         laeken_0.5.2      rbibutils_2.2.7   rvest_1.0.2      
[46] lifecycle_1.0.1   DEoptimR_1.0-10   MASS_7.3-54       zoo_1.8-9         scales_1.1.1     
[51] miscTools_0.6-26  hms_1.1.1         sandwich_3.0-1    yaml_2.2.1        bdsmatrix_1.3-4  
[56] stringi_1.7.6     bayestestR_0.11.5 e1071_1.7-9       boot_1.3-28       Rdpack_2.1.3     
[61] rlang_0.4.12      pkgconfig_2.0.3   evaluate_0.14     lattice_0.20-44   labeling_0.4.2   
[66] tidyselect_1.1.1  magrittr_2.0.1    R6_2.5.1          generics_0.1.1    DBI_1.1.2        
[71] pillar_1.6.4      withr_2.4.3       survival_3.2-11   datawizard_0.2.2  abind_1.4-5      
[76] sp_1.4-6          nnet_7.3-16       modelr_0.1.8      crayon_1.4.2      car_3.0-12       
[81] utf8_1.2.2        tzdb_0.2.0        rmarkdown_2.11    maxLik_1.5-2      readxl_1.3.1     
[86] data.table_1.14.2 vcd_1.4-9         reprex_2.0.1      digest_0.6.29     xtable_1.8-4     
[91] munsell_0.5.0     mitools_2.4

How do you knit ?

Using the "Knit" button in the RStudio IDE should run the rendering in the "Render" Pane and then open a HTML preview on the "Viewer" pane.

If you have no error, it should just work.

Do you get a HTML file without the results ?

Yes I use the "Knit" button in the R Studio. Everything runs smoothly and an HTML opens in the "Viewer" pane, but I only get an HTML without any results despite I have specified in the chunks that I want the results to be displayed.

Someting is not correct is your source file. The code chunks are not recognized as knitr chunks.
You only get one line source for the content of the chunk and their chunk header.

Is the document exactly the same as the content copied above ?

You could use the RStudio visual editor to help you identify what is going on.

Yes its exactly the same content as copied. I am sorry for the question, but how can I use the visual editor and find the problem? Thanks in advance.

The visual editor can be activated in RStudio with the visual menu icon from within the source pane with Rmd doc. Doc is here: Visual R Markdown

Do you have any message ?

Can you run

rmarkdown::render("yourfilename.Rmd") 

and see what it produces ?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.