title: Possible bug? R markdown cannot include ggplot figures
body: <p>I ran into a problem about markdown. In an ordinary R script, I click the Compile Report button (ctrl+shitf+k), and the result did not include any graphs. It took me some time before I figured out the fix is to delete the graphics.off() command in the heading. However, I have graph commands like ggplot or plot after the graphics.off() command. So why are all graphs deserted?</p>
  <p>Moreover, I am a Chinese user, and my computer is just the default coding in Win10 Simplified Chinese, not in UTF-8 coding. So sometimes I have errors like &quot;Error in abs_path(input) :
  The file 'D:/??/assignment 1/HW1.R' does not exist.&quot;, where the ?? are Chinese characters. I wonder if there is a way to fix this, while keeping my overall setting unchanged? I don't want to use the UTF-8 coding for my entire system, because I have some old txt files stored in other formats.</p>
  <p>Attached is the code that caused some trouble, and I used to add the command in the headings for housekeeping. More interestingly, last week this code works well with knitting, but this week I have to delete the graphics.off() command to have graphs in the knitted HTML file.</p>
  <pre><code>graphics.off() # Shuts down all open graphics
  rm(list = ls())  # Remove objects from the workspace
  # Set the working directory
  setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
  ##########
  #Problem 1
  ##########
  #question a
  library(XLConnect)#a very helpful package for excel sheets
  my_book = loadWorkbook(&quot;./HW1data/data_assignment1.xlsx&quot;)
  df = readWorksheet(my_book, sheet = &quot;stock_monthly&quot;)
  library(dplyr)
  library(tidyr)
  #transforming data into &quot;clean&quot; format
  df = gather( df, key = &quot;company&quot;, value = &quot;ret&quot;, -DATE ) 
  df[,1] = as.Date(as.character(df[,1]), format = &quot;%Y%m%d&quot;)  
    
    
  #question b
  df = df %&gt;% mutate(Lret =log(1 + ret)) #store the log result as Lret
  
  #question c
  library(ggplot2)
  #for simple return
  fig1 = ggplot(df, aes(x = DATE, y = ret))+
    geom_point(size = 0.5)+ facet_grid(rows = vars(company))
  print(fig1)
  </code></pre>
  <p>And the wrong output looks like this:</p>
  <p><img src="https://i.stack.imgur.com/4I3Lm.jpg" alt="The file ended without any figures, but the code executed correctly" /></p>