Search code examples
markdownr-markdownknitrfigure

Unable to view plots on .md file in GitHub


I created a R markdown file on R Studio and used the Knit function to create an html file. Eventually, .md file and html files were created in my working directory. Also, a figures folder/directory was created automatically. And hence, I pushed all the changes made to my GitHub repository.

Now, my problem here is when I open the .md (markdown) file on GitHub, it doesn't view the plots. It shows the link to it though. Attached a snippet for reference.

.md file on github

I tried a couple of things which didn't work:

  1. Added the below code chunk

    library(knitr)
    opts_chunk$set(dev="png")
    
  2. Impended ?raw=true end of the image link. I changed

    ![](PA1_template_files/figure-html/total number of steps taken each day-1.png) to

    ![](PA1_template_files/figure-html/total number of steps taken each day-1.png?raw=true)

I am using:

  • R-Studio Version : 1.0.143

  • Windows 7


Solution

  • Solved the problem!

    I removed spaces from code chunk names and it worked.

    I can now view plots/figures in the markdown file.

    One of the posts on R-studio support had me try this solution. Repeated google search helped.