简体   繁体   中英

Windows/Cygwin links in R

[originally posted at RStudio's support site , but it looks like it's a core R issue, not 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. 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. If I then do ls data/ , I can see the data files through the link.

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 . 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:

> 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.

A Windows shortcut isn't really a filesystem link. 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.

Have you tried using the mklink command to create the link, as described here ?

Disclaimer: I haven't tried it myself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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