RStudio升级1.0.44后opts_knit $ set(root.dir = path)不起作用 [英] opts_knit$set(root.dir = path) does not work after RStudio upgrade 1.0.44

查看:553
本文介绍了RStudio升级1.0.44后opts_knit $ set(root.dir = path)不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已升级到RStudio 1.0.44,看来knitr :: opts_knit $ set(root.dir = path)所在的路径是我的目录无法正常工作.它引发一条消息:

I upgraded to RStudio 1.0.44 and it seems knitr::opts_knit$set(root.dir = path) where path is my directory is not working as before. It throws a message:

The working directory was changed to /... inside a notebook chunk. The working
directory will be reset when the chunk is finished running. Use the knitr
root.dir option in the setup chunk to change the the working directory for
notebook chunks.

此消息现在将出现在以下每个命令中.请注意,我还没有编织rmd.我只是在运行命令.通过setwd()在命令行中直接设置工作目录将在getwd()中返回正确的路径,但是再次加载具有相对路径(./...)的文件将返回上述消息. RStudio 0.99.896可以使用完全相同的rmd.我想念什么?

This message will now appear in every following command. Note that I am not knitting the rmd yet. I'm just running commands out of it. Setting the working directory directly in command line via setwd() returns the correct path in getwd() but loading a file with relative path (./...) again would return above message. The exact same rmd works fine with RStudio 0.99.896. What am I missing?

sessionInfo()

R version 3.3.0 (2016-05-03)  
Platform: x86_64-w64-mingw32/x64 (64-bit)  
>Running under: Windows 7 x64 (build 7601) Service Pack 1  

other attached packages:
[1] scales_0.4.0     ggplot2_2.1.0    xtable_1.8-2     data.table_1.9.6  
[5] dplyr_0.4.3      knitr_1.15       pander_0.6.0 

推荐答案

您可以通过以下方式更改工作目录:

You can change the working directory with:

```{r "setup", include=FALSE}
knitr::opts_knit$set(root.dir = getwd())  # with something else than `getwd()`
```

,如rmarkdown网站中专用页面底部所述.

as described at the bottom of the dedicated page in rmarkdown website.

但是Restart R and run all chunks(可在RStudio的运行"选项卡中访问)解决了我机器上的相同问题.

But Restart R and run all chunks (accessible in the "Run>" tab in RStudio) fixed the very same problem on my machine.

有帮助吗?

这篇关于RStudio升级1.0.44后opts_knit $ set(root.dir = path)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆