conflict with RStudio and reading connections
Hey guys, I ran into a bug with R not downloading files properly when using RStudio. Can you all see if you can reproduce this?
http://stackoverflow.com/questions/6154497/r-reading-a-binary-file-...
-JD
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Josh Paulson on 27 May, 2011 04:25 PM
JD,
This seemed to work for me with both RStudio Server and Desktop. You are on server right? Can you check what specific version you are running with the following command:
Thanks,
Josh
3 Posted by jdlong on 27 May, 2011 05:46 PM
I'll grab the nightly and upgrade then report back.
4 Posted by jdlong on 27 May, 2011 05:54 PM
Nope, same problem even with 94.48.
Here's an example:
tst <- function(x){
p <- gzcon( url( "ftp://ftp.cpc.ncep.noaa.gov/precip/CPC_UNI_PRCP/GAUGE_GLB/V1.0/2005/PRCP_CU_GAUGE_V1.0GLB_0.50deg.lnx.20050101.gz" ) ) myPoints <- readBin(p, real(), n=1e6, size = 4, endian = "little") close(p) return(length(myPoints)) } sapply(1:10, tst)
returns
FWIW I'm on Ubuntu 11.04.
If I run the above from R in the command line, it works fine:
[1] 518400 518400 518400 518400 518400 518400 518400 518400 518400 518400
-JD
5 Posted by Luciano Selzer on 27 May, 2011 06:37 PM
Using RStudio 0.94.48 I get this
6 Posted by jdlong on 27 May, 2011 06:47 PM
Luciano, yes, that's the correct output. Are you using Rstudio Server on Ubuntu?
7 Posted by Luciano Selzer on 27 May, 2011 06:54 PM
No, RStudio desktop on Windows 7. I can dual boot to Ubuntu Natty. I'll get back with the test.
8 Posted by Luciano Selzer on 27 May, 2011 07:48 PM
I can confirm there's a bug. I think it only affects RStudio on ubuntu as it works well on Windows.
Output with RStudio:
Output with R in terminal
9 Posted by Luciano Selzer on 27 May, 2011 07:50 PM
I've just read my comment. The output in R terminal is also wrong on to ocassion. Could this be a timeout issue?
10 Posted by jdlong on 27 May, 2011 07:58 PM
Luciano, when i ran this from the command line R in ubuntu I consistently got the correct answer. When you say you see the bug in "R Terminal" do you mean on Ubuntu or Win?
Support Staff 11 Posted by Joe Cheng on 27 May, 2011 07:59 PM
I can repro on Natty server too. Investigating now.
Support Staff 12 Posted by Joe Cheng on 27 May, 2011 08:09 PM
Weird, every time I run:
download.file("ftp://ftp.cpc.ncep.noaa.gov/precip/CPC_UNI_PRCP/GAUGE_GLB/V1.0/2005/PRCP_CU_GAUGE_V1.0GLB_0.50deg.lnx.20050101.gz", "foo.gz")
it gives something like
downloaded length 149144 != reported length 179058
but with a different downloaded length every time. This repros with the "internal" download method but not "wget".
No workaround yet, still digging.
13 Posted by jdlong on 27 May, 2011 08:14 PM
Yep I get the very same thing.
Sent from my iPhone.
Support Staff 14 Posted by Joe Cheng on 27 May, 2011 08:18 PM
Hmmm, and only with this particular FTP server. This one works fine, for example:
15 Posted by jdlong on 27 May, 2011 08:23 PM
active vs. passive FTP issue?
16 Posted by jdlong on 27 May, 2011 08:39 PM
I've found a dependable workaround that tells me very little about the bug, unfortunately.
For the server which is giving me grief, if I call it through http instead of ftp, everything is fine. So instead of doing this using ftp:
tst <- function(x){
p <- gzcon( url( "ftp://ftp.cpc.ncep.noaa.gov/precip/CPC_UNI_PRCP/GAUGE_GLB/V1.0/2005/PRCP_CU_GAUGE_V1.0GLB_0.50deg.lnx.20050101.gz" ) ) myPoints <- readBin(p, real(), n=1e6, size = 4, endian = "little") close(p) return(length(myPoints)) } sapply(1:10, tst)
I do this:
tst <- function(x){
p <- gzcon( url( "http://ftp.cpc.ncep.noaa.gov/precip/CPC_UNI_PRCP/GAUGE_GLB/V1.0/200..." ) ) myPoints <- readBin(p, real(), n=1e6, size = 4, endian = "little") close(p) return(length(myPoints)) } sapply(1:10, tst)
Josh Paulson closed this discussion on 04 Oct, 2012 01:56 PM.