How to solve this error message in rmarkdown?

2019-04-19 00:59发布

问题:

I am just starting to explore the rmarkdown package. I don't use Rstudio. I use the default R environment. What I did was as follows.

I created a new R document. Started typing few lines in rmarkdown format. Saved the file with Rmd extension. I saved the file in the working directory. I installed the pandoc using the pkg file. I installed 'rmarkdown' package. Loaded the package. Used the following command to render the Rmd file.

rmarkdown::render("Untitled.Rmd")

I get the following error.

Error in tools::file_path_as_absolute(input) : file 'Untitled.Rmd' does not exist

I tried all the possible ways such as giving the exact path instead of filename etc. But nothing worked out. I googled the error message and found that none had similar error. Can someone help me with this. What I am missing. What the error message mean?

回答1:

Most of the time the error file not found is either a type error or a real missing file (as in your case, the real one is named in another way).

In order to discard those possibilities:

  1. Copy the fullpath from your filebrowser.
  2. Make sure the file exists, inside R you could type:

    file.exists("/fullpath/to/file")

If that return TRUE and the error persists, then you suspect another thing is going on.