6

I'm getting an error from gzip when reading an R data file. I'm trying to use the approach described here: Reading and writing RData files in Julia.

Here's a minimal example. In R, I run the following script:

var1 <- matrix( runif(9), 3, 3 )
save( var1, file='~/temp/file1.rda')

Then in julia:

using DataFrames
x = read_rda("~/temp/file1.rda")

This returns:

ERROR: GZip.GZError(-1,"gzopen failed")
 in gzopen at /home/squipbar/.julia/v0.4/GZip/src/GZip.jl:250
 in gzopen at /home/squipbar/.julia/v0.4/GZip/src/GZip.jl:265
 in read_rda at /home/squipbar/.julia/v0.4/DataFrames/src/RDA.jl:418

I don't think that I'm doing anything dumb. The closest I've found to this error online is in the RDatasets github issues, here: https://github.com/johnmyleswhite/RDatasets.jl/issues/32

So perhaps this is somehow related to RDatasets? Suggestions very welcome.

Community
  • 1
  • 1
squipbar
  • 667
  • 1
  • 5
  • 15
  • After the fact relevant links: http://stackoverflow.com/questions/24841448/setting-working-directory-julia-versus-r https://github.com/JuliaLang/julia/issues/1136 – squipbar Jul 14 '16 at 16:40

2 Answers2

6

As you found, tilde expansion is not automatic. You can use expanduser() to expand to the full file name.

julia> expanduser("~/Desktop")
"/Users/mycomputer/Desktop"
Randy Zwitch
  • 1,994
  • 1
  • 11
  • 19
4

Ok, I figured this one out. It's the expansion of "~" in the location. The following works:

using DataFrames
x = read_rda("/home/squipbar/temp/file1.rda")

So I guess I learnt two things here: 1) The error message for read_rda is not that helpful, a File not found message would have saved me a lot of time, and 2) that you can't use ~ in this case (is this a general thing in Julia?)

squipbar
  • 667
  • 1
  • 5
  • 15