简体   繁体   English

R中的Windows / Cygwin链接

[英]Windows/Cygwin links in R

[originally posted at RStudio's support site , but it looks like it's a core R issue, not RStudio.] [最初发布在RStudio的支持站点上 ,但它似乎是R的核心问题,而不是RStudio。]

I'm trying to figure out how to create a filesystem link that will be traversed within R. I've tried both Cygwin symlinks & Windows links to no avail. 我正在试图弄清楚如何创建一个将在R中遍历的文件系统链接。我已经尝试过Cygwin符号链接和Windows链接都无济于事。 I'm doing this because I've got a big directory full of large data files that I'd like to avoid copying to my workspace. 我这样做是因为我有一个大目录,里面装有大数据文件,我想避免复制到我的工作区中。

To create the symlink, I did ln -s ../otherdir/data data in Cygwin. 为了创建符号链接,我在Cygwin中做了ln -s ../otherdir/data data If I then do ls data/ , I can see the data files through the link. 如果我然后执行ls data/ ,我可以通过链接看到数据文件。

To create the Windows link, I did a "copy" in Windows Explorer on the otherdir/data/ directory, then did "paste shortcut" in my workspace and changed the name to data.lnk . 要创建Windows链接,我在Windows Explorer的otherdir/data/目录中进行了“复制”,然后在工作区中进行了“粘贴快捷方式”,并将名称更改为data.lnk If I double click that link, I'm taken correctly through the link. 如果我双击该链接,我通过链接正确。

So both links are correctly targeted. 因此,这两个链接都是正确的目标。

Now in RStudio, I get the following output, indicating that neither link can be traversed: 现在在RStudio中,我得到以下输出,表明两个链接都不能遍历:

> dir()
[1] "data" "data.lnk" "docs" "src" "tmp"
> dir('data')
character(0)
> dir('data.lnk')
character(0)
> dir('data/')
character(0)
> dir('data.lnk/')
character(0)

Is there some variation on this that will work? 是否有一些可行的变化? I'm using Windows 7 and R 2.13.1. 我正在使用Windows 7和R 2.13.1。

A Windows shortcut isn't really a filesystem link. Windows快捷方式实际上不是文件系统链接。 It's a regular file, that Explorer knows to treat differently. 这是一个常规文件,资源管理器知道要区别对待。 To other programs, it's just a file. 对于其他程序,它只是一个文件。

According to Wikipedia , a Cygwin symlink is implemented as a shortcut, rather than a true symbolic link, so it will have the same problem. 根据Wikipedia的说法,Cygwin符号链接是作为快捷方式而不是真正的符号链接实现的,因此它将具有相同的问题。

Have you tried using the mklink command to create the link, as described here ? 您是否尝试过使用mklink命令来创建链接,描述在这里

Disclaimer: I haven't tried it myself. 免责声明:我自己还没有尝试过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM