Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rio::import cannot load matlab file? #216

Closed
moldach opened this issue Sep 3, 2019 · 2 comments

Comments

@moldach
Copy link

commented Sep 3, 2019

rio::import() isn't working for a Matlab file (.mat) that i was able to load with R.matlab.

I used system.time() on R.matlab and it took about a minute. However, when I try to import with rio it just "freezes"/not-responding... after about 15 min I was forced to Terminate my Rstudio application.

I don't think you will include R.matlab due to dependencies ( issue# 24 ). However, rather than it just freezing like this, I think it should just throw an error and direct the user to this other package so they don't wait for ever thinking it's just a large dataset.

## load package
library("rio")
library("R.matlab")

## load 
system.time(x <- R.matlab::readMat("http://ufldl.stanford.edu/housenumbers/test_32x32.mat"))

user system elapsed
5.19 0.94 42.59

system.time(x <- rio::import("http://ufldl.stanford.edu/housenumbers/test_32x32.mat"))

Loading required namespace: rmatio

After this it's not-responding.

sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252   
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] R.matlab_3.6.2 rio_0.5.16     usethis_1.5.0  devtools_2.0.2

loaded via a namespace (and not attached):
 [1] zip_2.0.1          Rcpp_1.0.2         compiler_3.5.3     pillar_1.4.0      
 [5] cellranger_1.1.0   R.utils_2.9.0      R.methodsS3_1.7.1  prettyunits_1.0.2 
 [9] forcats_0.4.0      remotes_2.0.4      tools_3.5.3        testthat_2.0.1    
[13] digest_0.6.19      pkgbuild_1.0.3     pkgload_1.0.2      memoise_1.1.0.9000
[17] tibble_2.1.2       pkgconfig_2.0.2    rlang_0.4.0        openxlsx_4.1.0    
[21] cli_1.1.0          rstudioapi_0.10    curl_3.3           yaml_2.2.0        
[25] haven_2.1.0        withr_2.1.2        desc_1.2.0         fs_1.2.7          
[29] hms_0.4.2          rprojroot_1.3-2    glue_1.3.1         data.table_1.12.2 
[33] R6_2.4.0           processx_3.4.1     readxl_1.3.1       foreign_0.8-71    
[37] sessioninfo_1.1.1  callr_3.2.0        magrittr_1.5       backports_1.1.4   
[41] ps_1.3.0           assertthat_0.2.1   crayon_1.3.4       R.oo_1.22.0 

@leeper leeper added bug question and removed bug labels Sep 5, 2019

@leeper

This comment has been minimized.

Copy link
Owner

commented Sep 5, 2019

Thanks. I'll investigate.

@leeper

This comment has been minimized.

Copy link
Owner

commented Sep 9, 2019

This appears to be due to the underying matlab library that rio uses (which is rmatio, rather than R.matlab). On my machine it definitely hangs and runs much more slowly than R.matlab, but it does execute successfully:

> system.time(x <- R.matlab::readMat("http://ufldl.stanford.edu/housenumbers/test_32x32.mat"))
Registered S3 method overwritten by 'R.oo':
  method        from       
  throw.default R.methodsS3
   user  system elapsed 
   7.65    2.25   27.08 
> system.time(x <- rmatio::read.mat("http://ufldl.stanford.edu/housenumbers/test_32x32.mat"))
   user  system elapsed 
  34.54  109.36  161.91 
> system.time(x <- rio::import("http://ufldl.stanford.edu/housenumbers/test_32x32.mat"))
   user  system elapsed 
  97.75  131.48  308.01

I would suggest reporting the speed difference to: https://github.com/stewid/rmatio/issues

@leeper leeper closed this Sep 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.