How to create a MacOS / Linux link to read a data file?

I have a huge raw data file that I am not going to modify or copy. And I have two projects in RStudio, and both must have access to it.

I initially created an alias (on MacOS) as follows, right-click the file ~/A/data.csvin finder and click "make alias". Then copy the alias to ~/B/and rename it~/B/data.csv

I also tried the following command later ln -s ~/A/data.csv ~/B

For project A, I put the actual data file in A / data / data.csv.
For project B, I created an alias under B / data /.

But when I try fread ('B / data / data.csv'), it complains:

sh: ./ data / data.csv: Too many levels of symbolic links

Error in the fread file ("./data/data.csv"):

The file is empty: / var / folders / 4h / 2jg64xk52mv3fyq4sb7s371w0000gn / T // Rtmp7cWNN3 / filebf3013ad9194

I think I can use a hard link to solve this problem, but just want to see if I can use an alias so that it works.

===== I do not think this is important, but for completeness, see the following for my OS and R version:

platform       x86_64-apple-darwin10.8.0   
arch           x86_64                      
os             darwin10.8.0                
system         x86_64, darwin10.8.0        
status                                     
major          3                           
minor          1.0                         
year           2014                        
month          04                          
day            10                          
svn rev        65387                       
language       R                           
version.string R version 3.1.0 (2014-04-10)
nickname       Spring Dance    
+4
source share
1 answer

I do not quite understand why using aliases in this particular case:

  • note that for small files (e.g. <1 MB), an alias may have more memory. For example, for a simple text file containing "test" ( echo "test" > test.txt), the alias will be 274 times larger:

test.txt: 5 bytes

test.txt identifier: 1372636 bytes

  • RStudio , ~/A/data.csv, ?

( ) , (1) (2) .

#!/bin/bash
mkdir ~/B/data/
cp ~/A/data.csv ~/B/data/

R, system ( Mac):

system("mkdir ~/B/data/")
system("cp ~/A/data.csv ~/B/data/")

, ~/A/data.csv ~/B/data/.

:

#!/bin/bash
mkdir ~/B/data/
echo "~/A/data.csv" > ~/B/data/data.csv

( R system(), ) , R:

## Reading path in B/data/
PATH <- scan(file = "~/B/data/data.csv", what = character())
## Opening the file (~/A/data/data.csv)
my_csv <- read.csv(PATH)
+1

All Articles