[R-sig-finance] Behaviour of get.hist.quote when presented with bad inputs

Dirk Eddelbuettel edd at debian.org
Tue May 9 12:20:28 CEST 2006


Hi Ajay,

On 9 May 2006 at 14:41, Ajay Narottam Shah wrote:
| With R 2.3, when I say get.hist.quote("rubbish") he gets extremely unhappy:
| 
| > library(tseries)
| Loading required package: quadprog
| Loading required package: zoo
| > x <- get.hist.quote("rubbish")
| trying URL
| 'http://chart.yahoo.com/table.csv?s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.csv'
| 
|  *** caught segfault ***
| address 0x5f4d4550, cause 'memory not mapped'
| 
| Traceback:
|  1: download.file(url, destfile, method = method)
|  2: get.hist.quote("rubbish")
| 
| Possible actions:
| 1: abort (with core dump)
| 2: normal R exit
| 3: exit R without saving workspace
| 4: exit R saving workspace
| Selection: c
| 
| I believe that before R 2.3, it was not so bad - there was no segfault
| when a bad input was presented. I feel that it's enough to return NULL
| when presented with "rubbish", but segfaulting is kinda extreme.
| 
| I tried to say
|   > try(x <- get.hist.quote("rubbish"))
| but that also segfaults.
| 
| How can I do better?
| 
| My machine is an ibook running an uptodate copy of OS X "tiger".
| $ uname -a
| Darwin lubyanka.local 8.6.0 Darwin Kernel Version 8.6.0: Tue Mar  7 16:58:48 PST 2006; root:xnu-792.6.70.obj~1/RELEASE_PPC Power Macintosh powerpc

Looks like it is a Mac issue as it works fine here. I'm CCing Simon.

One other thing you could try is to set the option() argument for the
downloader to use the external wget command instead of the built-in solution.
That may prevent the segfault.

Hth, Dirk

edd at basebud:~> R

R : Copyright 2006, The R Foundation for Statistical Computing
Version 2.3.0 (2006-04-24)
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(tseries)
Loading required package: quadprog
Loading required package: zoo
Warning message:
use of NULL environment is deprecated
>  x <- get.hist.quote("rubbish")
trying URL 'http://chart.yahoo.com/table.csv?s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.csv'
Error in download.file(url, destfile, method = method) :
        cannot open URL 'http://chart.yahoo.com/table.csv?s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.csv'
In addition: Warning message:
cannot open: HTTP status was '404 Not Found'
>



| 
| -- 
| Ajay Shah                                      http://www.mayin.org/ajayshah  
| ajayshah at mayin.org                             http://ajayshahblog.blogspot.com
| <*(:-? - wizard who doesn't know the answer.
| 
| _______________________________________________
| R-sig-finance at stat.math.ethz.ch mailing list
| https://stat.ethz.ch/mailman/listinfo/r-sig-finance

-- 
Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison



More information about the R-sig-finance mailing list