Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gzip error when reading R data files into julia

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.

like image 523
squipbar Avatar asked Jun 21 '16 20:06

squipbar


1 Answers

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"
like image 161
Randy Zwitch Avatar answered Sep 20 '22 23:09

Randy Zwitch