Re: [Rd] 0.5 != integrate(dnorm,0,20000) = 0

2010-12-13 Thread Stavros Macrakis
I'd suggest that the original sin here is calling some particular
numerical integration routine 'integrate', which gives the user an
illusory sense of power Functions have to be well-behaved in
various ways for quadrature to work well, and you've got to expect
things like

> integrate(function(x)tan(x),0,pi)
Error in integrate(function(x) tan(x), 0, pi) :
  roundoff error is detected in the extrapolation table   <<< a 'good'
error -- tells the user something's wrong
> integrate(function(x)tan(x)^2,0,pi)
1751.054 with absolute error < 0  <<< oops
> integrate(function(x)1/(x-pi/2)^2,0,pi) <<< the same 
> pole (analytically)
Error in integrate(function(x) 1/(x - pi/2)^2, 0, pi) : <<<
gets a useful error in this form
  non-finite function value

But by that argument, I suppose you shouldn't call floating-point
addition "+" :-)

-s

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] errors in getconnection or scan

2010-12-13 Thread Arthur Charpentier
great, exactly what I've being looking for !
thanks a lot !

2010/12/13 Duncan Murdoch 

> On 13/12/2010 12:56 PM, Arthur Charpentier wrote:
>
>> sorry... localization is a string of characters
>> for instance
>> localization =
>> paste("http://www.resultsfromtennis.com/
>> ",year,"/atp/",city,".html",sep="")
>> where year is 2006 and city can be "wimbledon"
>> hence here, since the page
>> "http://www.resultsfromtennis.com/2007/atp/wimbledon.html"; does exist, I
>> can get the tables inside
>> but
>> "http://www.resultsfromtennis.com/1977/atp/shertogenbosch.html";
>> does not exist... is there a way to detect that the html page does not
>> exist ?
>>
>
> If you try to read it and get an error, you will know there's a problem.
>  For example,
>
> x <- "http://cran.r-project.ogr";  # has a typo
> con <- url(x)
> html <- readLines(con)
>
> This should produce an error, but might give you a junk page if your DNS
> provider substitutes for it.  You can catch the error using
>
> html <- try(readLines(con), silent=TRUE)
> if (inherits(html, "try-error")) cat("Error!")
>
> Duncan Murdoch
>
>
>>
>> 2010/12/13 Duncan Murdoch > >
>>
>>
>>On 13/12/2010 12:36 PM, Arthur Charpentier wrote:
>>
>>I was wondering if there was a function like "does connection
>>exists" ?
>>
>>
>>See ?showConnections.
>>
>>
>>I am currently using loops to build up a database, and I have
>> either
>>
>>  B = getConnection(localization)
>>
>>Error in getConnection(localization) : there is no connection
>>-2147483648
>>In addition: Warning message:
>>In getConnection(localization) : NAs introduced by coercion
>>
>>
>>Where did the localization variable come from?  getConnection is
>>pretty rarely used.
>>
>>
>>
>>or
>>
>>  B = scan(localization)
>>
>>Error in file(file, "r") : cannot open the connection
>>In addition: Warning message:
>>In file(file, "r") : cannot open: HTTP status was '404 Not Found'
>>
>>is there a way to test where localization is an html page, or
>>not ? and to
>>say that if localization does exist, then scan it ?
>>
>>
>>What's your definition of an html page?  Testing for valid html is
>> hard.
>>
>>Duncan Murdoch
>>
>>
>>
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] errors in getconnection or scan

2010-12-13 Thread Duncan Murdoch

On 13/12/2010 12:56 PM, Arthur Charpentier wrote:

sorry... localization is a string of characters
for instance
localization =
paste("http://www.resultsfromtennis.com/",year,"/atp/",city,".html",sep="";)
where year is 2006 and city can be "wimbledon"
hence here, since the page
"http://www.resultsfromtennis.com/2007/atp/wimbledon.html"; does exist, I
can get the tables inside
but
"http://www.resultsfromtennis.com/1977/atp/shertogenbosch.html";
does not exist... is there a way to detect that the html page does not
exist ?


If you try to read it and get an error, you will know there's a problem. 
 For example,


x <- "http://cran.r-project.ogr";  # has a typo
con <- url(x)
html <- readLines(con)

This should produce an error, but might give you a junk page if your DNS 
provider substitutes for it.  You can catch the error using


html <- try(readLines(con), silent=TRUE)
if (inherits(html, "try-error")) cat("Error!")

Duncan Murdoch




2010/12/13 Duncan Murdoch mailto:murdoch.dun...@gmail.com>>

On 13/12/2010 12:36 PM, Arthur Charpentier wrote:

I was wondering if there was a function like "does connection
exists" ?


See ?showConnections.


I am currently using loops to build up a database, and I have either

  B = getConnection(localization)

Error in getConnection(localization) : there is no connection
-2147483648
In addition: Warning message:
In getConnection(localization) : NAs introduced by coercion


Where did the localization variable come from?  getConnection is
pretty rarely used.



or

  B = scan(localization)

Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") : cannot open: HTTP status was '404 Not Found'

is there a way to test where localization is an html page, or
not ? and to
say that if localization does exist, then scan it ?


What's your definition of an html page?  Testing for valid html is hard.

Duncan Murdoch




__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] errors in getconnection or scan

2010-12-13 Thread Arthur Charpentier
sorry... localization is a string of characters
for instance
localization = paste("http://www.resultsfromtennis.com/
",year,"/atp/",city,".html",sep="")
where year is 2006 and city can be "wimbledon"
hence here, since the page "
http://www.resultsfromtennis.com/2007/atp/wimbledon.html"; does exist, I can
get the tables inside
but
"http://www.resultsfromtennis.com/1977/atp/shertogenbosch.html";
does not exist... is there a way to detect that the html page does not exist
?


2010/12/13 Duncan Murdoch 

> On 13/12/2010 12:36 PM, Arthur Charpentier wrote:
>
>> I was wondering if there was a function like "does connection exists" ?
>>
>
> See ?showConnections.
>
>
>  I am currently using loops to build up a database, and I have either
>>
>>   B = getConnection(localization)
>>>
>> Error in getConnection(localization) : there is no connection -2147483648
>> In addition: Warning message:
>> In getConnection(localization) : NAs introduced by coercion
>>
>
> Where did the localization variable come from?  getConnection is pretty
> rarely used.
>
>
>
>> or
>>
>>   B = scan(localization)
>>>
>> Error in file(file, "r") : cannot open the connection
>> In addition: Warning message:
>> In file(file, "r") : cannot open: HTTP status was '404 Not Found'
>>
>> is there a way to test where localization is an html page, or not ? and to
>> say that if localization does exist, then scan it ?
>>
>
> What's your definition of an html page?  Testing for valid html is hard.
>
> Duncan Murdoch
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] errors in getconnection or scan

2010-12-13 Thread Duncan Murdoch

On 13/12/2010 12:36 PM, Arthur Charpentier wrote:

I was wondering if there was a function like "does connection exists" ?


See ?showConnections.


I am currently using loops to build up a database, and I have either


  B = getConnection(localization)

Error in getConnection(localization) : there is no connection -2147483648
In addition: Warning message:
In getConnection(localization) : NAs introduced by coercion


Where did the localization variable come from?  getConnection is pretty 
rarely used.




or


  B = scan(localization)

Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") : cannot open: HTTP status was '404 Not Found'

is there a way to test where localization is an html page, or not ? and to
say that if localization does exist, then scan it ?


What's your definition of an html page?  Testing for valid html is hard.

Duncan Murdoch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] errors in getconnection or scan

2010-12-13 Thread Arthur Charpentier
I was wondering if there was a function like "does connection exists" ?
I am currently using loops to build up a database, and I have either

>  B = getConnection(localization)
Error in getConnection(localization) : there is no connection -2147483648
In addition: Warning message:
In getConnection(localization) : NAs introduced by coercion

or

>  B = scan(localization)
Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") : cannot open: HTTP status was '404 Not Found'

is there a way to test where localization is an html page, or not ? and to
say that if localization does exist, then scan it ?

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel