[R-SIG-Mac] source() hangs on import

Robert J Goedman goedman at icloud.com
Sat May 18 17:14:16 CEST 2013


Don,

Slightly modified, your example:

N <- 5e4

cat('Create myfile\n')
system.time(myfile <- data.frame(x1=runif(N),x2=runif(N),x3=runif(N)))
head(myfile)

cat('\nSave myfile\n')
system.time(save("myfile",file="./R/R_projects/R Support/Debug/myfile.RData"))
remove(myfile)

cat('Load myfile\n')
system.time(load("./R/R_projects/R Support/Debug/myfile.RData"))
head(myfile)

cat('\nDump myfile\n')
system.time(dump("myfile",file="./R/R_projects/R Support/Debug/myfile.R"))
remove(myfile)

cat('Source myfile\n')
system.time(source("./R/R_projects/R Support/Debug/myfile.R"))
head(myfile)

produces:

> source('/Users/rob/Projects/R/R_projects/R support/Debug/DumpAndSave_test.r', print.eval=TRUE)
Create myfile
   user  system elapsed 
  0.005   0.001   0.006 
           x1        x2         x3
1 0.611084090 0.4841179 0.47273937
2 0.596409008 0.2234015 0.19283019
3 0.273999461 0.7524927 0.02346372
4 0.691567956 0.4921780 0.48312317
5 0.001781206 0.1211497 0.12041949
6 0.002494183 0.6935539 0.23262610

Save myfile
   user  system elapsed 
  0.161   0.001   0.162 
Load myfile
   user  system elapsed 
  0.007   0.001   0.008 
           x1        x2         x3
1 0.611084090 0.4841179 0.47273937
2 0.596409008 0.2234015 0.19283019
3 0.273999461 0.7524927 0.02346372
4 0.691567956 0.4921780 0.48312317
5 0.001781206 0.1211497 0.12041949
6 0.002494183 0.6935539 0.23262610

Dump myfile
   user  system elapsed 
  0.335   0.005   0.338 
Source myfile
   user  system elapsed 
 22.252   0.238  22.440 
           x1        x2         x3
1 0.611084090 0.4841179 0.47273937
2 0.596409008 0.2234015 0.19283019
3 0.273999461 0.7524927 0.02346372
4 0.691567956 0.4921780 0.48312317
5 0.001781206 0.1211497 0.12041949
6 0.002494183 0.6935539 0.23262610

For N=1e5, the elapsed time for source() is ~100seconds. It is slow, but eventually will return on my machine .

Regards,
Rob J. Goedman
goedman at icloud.com




On May 17, 2013, at 7:16 PM, Don McKenzie <dmck at u.washington.edu> wrote:

> Yes. Duh.  Overthinking the "reproducible" part and responding too quickly.  Here's one that produces the behavior.
> 
> myfile <- data.frame(x1=runif(100000),x2=runif(100000),x3=runif(100000))
> dump("myfile",file="myfileR")
> source("myfileR")
> 
> The source() part takes ~10 sec. in R 2.9.2 on my old powermac, but hangs in 3.0.0.
> 
> Don
> 
> 
> On 17-May-13, at 6:51 PM, Simon Urbanek wrote:
> 
>> 
>> On May 17, 2013, at 9:41 PM, Donald McKenzie wrote:
>> 
>>> Simon -- I can't reproduce it for the list because the window it's running in always hangs and R freezes. I tried. But it basically looks like
>>> 
>>>> dump("my.file",file="myfileR")
>>>> source("myfileR")
>>> HANG..... (yellow colored ball)
>>> 
>> 
>> Well, you can simply provide the myfileR that hangs for you ...
>> 
>> Cheers,
>> Simon
>> 
>> 
>>> I will go with your suggestions below and report back if need be.   Thanks for the help.
>>> 
>>> Don
>>> 
>>> On Fri, 17 May 2013, Simon Urbanek wrote:
>>> 
>>>> 
>>>> On May 17, 2013, at 7:20 PM, Don McKenzie wrote:
>>>> 
>>>>> I checked the archives since the release of R 3.0.0 and didn't see anything on this.
>>>>> 
>>>>> Trying to import data previously exported with dump(), source() hangs and I have to force quit R.  This happens with data objects
>>>>> as small as 5 kb.
>>>> 
>>>> Do you have a reproducible example?
>>>> 
>>>> 
>>>>> Has anyone encountered this and found a workaround?  Is there now a preferred method to export R objects?
>>>>> 
>>>> 
>>>> The preferred method has always been to use serialization (save/load or saveRDS/readRDS).
>>>> 
>>>> Cheers,
>>>> Simon
>>>> 
>>>> 
>>>>> Thanks for any suggestions.
>>>>> 
>>>>> on a macbook pro with 4 gb RAM.
>>>>> 
>>>>>> 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          0.0
>>>>> year           2013
>>>>> month          04
>>>>> day            03
>>>>> svn rev        62481
>>>>> language       R
>>>>> version.string R version 3.0.0 (2013-04-03)
>>>>> nickname       Masked Marvel
>>>>> 
>>>>> 
>>>>> 
>>>>> Don McKenzie
>>>>> Research Ecologist
>>>>> Pacific Wildland Fire Sciences Lab
>>>>> US Forest Service
>>>>> 
>>>>> Affiliate Professor
>>>>> School of Environmental and Forest Sciences
>>>>> University of Washington
>>>>> 
>>>>> phone: 206-732-7824
>>>>> dmck at uw.edu
>>>>> 
>>>>> _______________________________________________
>>>>> R-SIG-Mac mailing list
>>>>> R-SIG-Mac at r-project.org
>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>>>> 
>>>>> 
>>>> 
>>>> _______________________________________________
>>>> R-SIG-Mac mailing list
>>>> R-SIG-Mac at r-project.org
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>>> 
>>> 
>>> 
>> 
> 
> 
> 
> 
> 
> Don McKenzie, Research Ecologist
> Pacific Wildland Fire Sciences Lab
> US Forest Service
> phone: 206-732-7824
> 
> Affiliate Professor
> School of Environmental and Forest Sciences
> University of Washington
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list