Rstudio is deleting key files when I knit (both PD

2019-02-15 21:16发布

问题:

So I am having an R nightmare. I've returned to a project I built under the previous iteration (or perhaps one more) of RStudio. I produced a workable report that I was asked to update, and my current bugbear wasn't around then. Here is what happens:

  1. My report file is "ISS Time Series.Rmd". It calls three other files:
    • "mystyles.sty", which updates the LaTeX preamble to use some additional packages.
    • "functions.R" and "load.R". The former contains frequently used functions I've written, and the latter loads the data I'm using.
  2. I source the two R functions in the .Rmd file. When I try to Knit the report, whether I get an error or am successful, my two .R files and my one .sty file are deleted. And not just deleted -- gone for good.

I do not know what is up. I have ruined my previous work simply by returning to examine the original file.

Please, somebody has to help me here. My workflow is shot to hell if I have to write every last bit of code over and over again in each report.

UPDATE: Even copying the files to another directory doesn't help.

Here is the code block that calls the "load.R" file:

```{r loaddata}
#
# ------- Load Data
#
# This section loads the ISS survey files one at a time and saves them as 
# read.SPSS objects within a list. It names these eleven objects as "ISS 2002",
# "ISS 2003", etc... until "ISS 2012". This file may be prohibitively large.
#
source("load.R")    # Loads the ISS Survey files

```

回答1:

Rename your file to ISS_Time_Series.Rmd and try again.

It is the spaces in the document name that makes rmarkdown::render() delete the files that have been loaded or sourced.

A an issue has already been filed. See https://github.com/rstudio/rmarkdown/issues/580



标签: r rstudio