[Rd] HTML help

2009-04-15 Thread Jack (Zhan, Hua Ping)
Hi,guys,

HTML help is not right for math formula:
For example:
I got the following formula in help page of ca.jo in urca package:

X_t = Pi_1 X_{t-1} + ... + Pi_k
X_{t-k} + μ + Phi D_t + varepsilon_t
, quad (t = 1, ..., T),


This presentation is just not good, however, in most browser,
with tag , the formula in the tag works well.
such as in wikipedia. please check the same formula:
http://en.wikipedia.org/wiki/Johansen_test

Can someone please fix this?
help(ca.jo,offline=TRUE), we can get the formula right.

The problem seems to occur at the building process. Latex output is
right, but the HTML output is not good for math formula.

I guess this issue is not so difficult.

-- 
with best regards
Jack (Zhan, Hua Ping)
+1-514-8800518

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


Re: [Rd] Automatic Differentiation for R

2009-04-15 Thread John C Nash

In efforts to improve optimization tools for R, one of my
interests has been getting automatic differentiation capabilities
so that analytic rather than numerical derivatives can be used. They
would be helpful in several other areas besides optimization, My timings 
show

factors of the order of 1000s in time improvements by avoiding
numerical derivatives in some cases.

There has been some work in this e.g., 
http://code.google.com/p/pbs-software/
is an R interface to ADMB (Automatic Differentiation Model Builder). 
However,
as far as I can see, this is directed essentially to nonlinear least 
squares modelling,

an important but not general problem.

Tom Coleman of Waterloo responded favourably with some advice, but the most
enthusiastic answer came from Shaun Forth, which I have included below. 
I read
this as an opportunity to develop what could be a profitable 
collaboration with
the AD community. Unfortunately, I cannot take up the invitation to join 
the AD
folk in Oxford due to a pre-existing obligation. Nor am I more than a 
complete
novice with S3 and S4 classes etc. I am, nevertheless, willing to help 
organize

the effort e.g., do some of the communications, chasing grant money, getting
Google Summer of Code applications filled in etc.

Can the R community come up with a few people who can provide the AD
workers with appropriate information? If so, is there a reasonable chance to
generate sufficient funding for a student? I suspect the answer in both 
cases

is yes, but that we need some form of "booster cables" to get things going.
(In Canada, booster cables are used to get cars started in winter by 
connecting

a running vehicle's battery to that of a dead one.)

I suggest communications off-list until there is progress to report. 
Possibly

there is a better forum for this -- suggestions welcome.

John Nash

 included msg from Shaun Forth ---

Hi John,
My computational statistics colleague Trevor Ringrose has asked me to
consider AD in R in the past. As you may or may not be aware AD is
implemented in one of two ways: overloading using OO features of the
target language, or source transformation using compiler tools (after
several man years of development) to read in the target code and spit
out the differentiated code. Last time I looked I didn't think the
object oriented features of R were up to overloading but on checking
today I can see that this might now be possible (I can see overloading
of arithmetic operators and functions for example now which I didn't see
last time).  


I'd certainly be interested in following this up particularly on the
overloading side but would need to get funding for a PhD student to do
the graft. It would be particularly interesting doing this in an open
source language because we could then perhaps tweak some of the core
language features if they didn't seamlessly support the AD (we can't do
this in Matlab and that is a pain!).

My immediate suggestion is that you, or some other more local (to UK) R
expert talks at the next European AD workshop in Oxford 
http://www.autodiff.org/?module=Workshops&submenu=EuroAD/8/main

We're a very friendly group and I'm sure there are others who might like
to tackle R or perhaps we could put together a multigroup project. If
someone could give a talk on R, its language features including the OO
aspects, and some optimisation examples with associated code, the group
there would be able to give you the best feedback on the planet on the
possibilities.

Please do treat this as a positive response and let's keep in touch on
this.

Regards

Shaun



Dr Shaun Forth
Applied Mathematics & Scientific Computation
Cranfield Defence and Security 
Cranfield University, Shrivenham Campus 
Swindon SN6 8LA, England

tel: +44 (0)1793 785311
fax: +44 (0)1793 784196
email: s.a.fo...@cranfield.ac.uk
http://www.amorg.co.uk
#

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


Re: [Rd] Automatic Differentiation for R

2009-04-15 Thread Gabor Grothendieck
Not sure if this is sufficient for your needs but R does include symbolic
differentiation, see ?D, and the Ryacas and rSymPy
packages interface R to the yacas and sympy computer algebra
systems (CAS) and those system include symbolic differentiation.

http://ryacas.googlecode.com
http://rsympy.googlecode.com

Note that Ryacas communicates with yacas via XML but recent
versions of the XML package changed in a way that breaks
Ryacas so you will likely have to use an old version of XML
and Ryacas if you want to try that one -- see home page.

The rsympy interface is early stage but its functional and is
easier to install since it includes the entire CAS right in
the R package.

On Wed, Apr 15, 2009 at 9:30 AM, John C Nash  wrote:
> In efforts to improve optimization tools for R, one of my
> interests has been getting automatic differentiation capabilities
> so that analytic rather than numerical derivatives can be used. They
> would be helpful in several other areas besides optimization, My timings
> show
> factors of the order of 1000s in time improvements by avoiding
> numerical derivatives in some cases.
>
> There has been some work in this e.g.,
> http://code.google.com/p/pbs-software/
> is an R interface to ADMB (Automatic Differentiation Model Builder).
> However,
> as far as I can see, this is directed essentially to nonlinear least squares
> modelling,
> an important but not general problem.
>
> Tom Coleman of Waterloo responded favourably with some advice, but the most
> enthusiastic answer came from Shaun Forth, which I have included below. I
> read
> this as an opportunity to develop what could be a profitable collaboration
> with
> the AD community. Unfortunately, I cannot take up the invitation to join the
> AD
> folk in Oxford due to a pre-existing obligation. Nor am I more than a
> complete
> novice with S3 and S4 classes etc. I am, nevertheless, willing to help
> organize
> the effort e.g., do some of the communications, chasing grant money, getting
> Google Summer of Code applications filled in etc.
>
> Can the R community come up with a few people who can provide the AD
> workers with appropriate information? If so, is there a reasonable chance to
> generate sufficient funding for a student? I suspect the answer in both
> cases
> is yes, but that we need some form of "booster cables" to get things going.
> (In Canada, booster cables are used to get cars started in winter by
> connecting
> a running vehicle's battery to that of a dead one.)
>
> I suggest communications off-list until there is progress to report.
> Possibly
> there is a better forum for this -- suggestions welcome.
>
> John Nash
>
>  included msg from Shaun Forth ---
>
> Hi John,
> My computational statistics colleague Trevor Ringrose has asked me to
> consider AD in R in the past. As you may or may not be aware AD is
> implemented in one of two ways: overloading using OO features of the
> target language, or source transformation using compiler tools (after
> several man years of development) to read in the target code and spit
> out the differentiated code. Last time I looked I didn't think the
> object oriented features of R were up to overloading but on checking
> today I can see that this might now be possible (I can see overloading
> of arithmetic operators and functions for example now which I didn't see
> last time).
> I'd certainly be interested in following this up particularly on the
> overloading side but would need to get funding for a PhD student to do
> the graft. It would be particularly interesting doing this in an open
> source language because we could then perhaps tweak some of the core
> language features if they didn't seamlessly support the AD (we can't do
> this in Matlab and that is a pain!).
>
> My immediate suggestion is that you, or some other more local (to UK) R
> expert talks at the next European AD workshop in Oxford
> http://www.autodiff.org/?module=Workshops&submenu=EuroAD/8/main
> We're a very friendly group and I'm sure there are others who might like
> to tackle R or perhaps we could put together a multigroup project. If
> someone could give a talk on R, its language features including the OO
> aspects, and some optimisation examples with associated code, the group
> there would be able to give you the best feedback on the planet on the
> possibilities.
>
> Please do treat this as a positive response and let's keep in touch on
> this.
>
> Regards
>
> Shaun
>
>
> 
> Dr Shaun Forth
> Applied Mathematics & Scientific Computation
> Cranfield Defence and Security Cranfield University, Shrivenham Campus
> Swindon SN6 8LA, England
> tel: +44 (0)1793 785311
> fax: +44 (0)1793 784196
> email: s.a.fo...@cranfield.ac.uk
> http://www.amorg.co.uk
> #
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailma

Re: [Rd] HTML help

2009-04-15 Thread Simon Urbanek

JAck,

On Apr 14, 2009, at 22:50 , Jack (Zhan, Hua Ping) wrote:


Hi,guys,

HTML help is not right for math formula:
For example:
I got the following formula in help page of ca.jo in urca package:

X_t = Pi_1 X_{t-1} + ... +  
Pi_k

X_{t-k} + μ + Phi D_t + varepsilon_t
, quad (t = 1, ..., T),


This presentation is just not good, however, in most browser, with  
tag , the formula in the tag works well.


I don't see what you mean - just putting  tags around the above  
doesn't change rendering at all. Moreover  is not a valid tag in  
the HTML standard.




such as in wikipedia. please check the same formula: 
http://en.wikipedia.org/wiki/Johansen_test



Wikipedia uses bitmaps to represent those formulae, there are no HTML  
 tags involved there.




Can someone please fix this?
help(ca.jo,offline=TRUE), we can get the formula right.

The problem seems to occur at the building process. Latex output is
right, but the HTML output is not good for math formula.

I guess this issue is not so difficult.



Well, then fix it and send us the patch please ...

Cheers,
Simon

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


[Rd] Correction to documentation of print.ls_str in utils package

2009-04-15 Thread Brian Diggs
In the documentation for print.ls_str (on the ls.str page) in the utils 
package, the description for max.level is not correct.  It says "Default 0: 
Display all nesting levels."  The default, according to the Usage on that page 
and the source code, is 1. Also, a value of 0 does not display all the nesting 
levels; NA does that (based on the documentation of str). A value of 0 does not 
display any nested levels. I recommend changing that sentence to "If NA, 
display all nesting levels. Default 1: Display only the first nested level."

--
Brian Diggs, Ph.D.
Senior Research Associate, Department of Surgery, Oregon Health & Science 
University



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


Re: [Rd] HTML help

2009-04-15 Thread mnorton52

Hi Jack,

I'm not sure about the  tag either, and it didn't work when I tried
it.  I think the approach this web page uses may help in writing
mathematical symbols to HTML:

http://comers.citadel.edu/math_sym2005.htm

Cheers,
Mike


Jack (Zhan, Hua Ping) wrote:
> 
> 
> HTML help is not right for math formula:
> For example:
> I got the following formula in help page of ca.jo in urca package:
> 
> X_t = Pi_1 X_{t-1} + ... + Pi_k
> X_{t-k} + μ + Phi D_t + varepsilon_t
> , quad (t = 1, ..., T),
> 
> 
> This presentation is just not good, however, in most browser,
> with tag , the formula in the tag works well.
> such as in wikipedia. please check the same formula:
> http://en.wikipedia.org/wiki/Johansen_test
> 
> -- 
> with best regards
> Jack (Zhan, Hua Ping)
> +1-514-8800518
> 
> 

-- 
View this message in context: 
http://www.nabble.com/HTML-help-tp23054298p23063793.html
Sent from the R devel mailing list archive at Nabble.com.

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


Re: [Rd] HTML help

2009-04-15 Thread Romain Francois

Hi,

if the system that builds the html help page is latex capable, then it 
would not be too difficult to use the same trick wikipedia is using 
(generating a png file for each equation). Translating latex style 
markup into mathml is another game, see this: 
http://www1.chapman.edu/~jipsen/mathml/asciimath.html for example.


Romain

mnorton52 wrote:

Hi Jack,

I'm not sure about the  tag either, and it didn't work when I tried
it.  I think the approach this web page uses may help in writing
mathematical symbols to HTML:

http://comers.citadel.edu/math_sym2005.htm

Cheers,
Mike


Jack (Zhan, Hua Ping) wrote:
  

HTML help is not right for math formula:
For example:
I got the following formula in help page of ca.jo in urca package:

X_t = Pi_1 X_{t-1} + ... + Pi_k
X_{t-k} + μ + Phi D_t + varepsilon_t
, quad (t = 1, ..., T),


This presentation is just not good, however, in most browser,
with tag , the formula in the tag works well.
such as in wikipedia. please check the same formula:
http://en.wikipedia.org/wiki/Johansen_test

--
with best regards
Jack (Zhan, Hua Ping)
+1-514-8800518



--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

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


[Rd] (Not quite) Automatic Differentiation

2009-04-15 Thread John C Nash
Many thanks to Gabor Grothendieck for responding to my posting about 
Automatic Differentiation (invite from Shaun Forth for interaction with 
R developers) showing how one might use rSymPy and symbolic (rather than 
automatic) differentiation to get a function that computes gradients. 
See 
http://code.google.com/p/rsympy/#Automatic_Differentiation_(well,_sort_of)  
for a worked example on the Broyden test function.


This is a big step forward. There's still a way to go before we can 
produce a vectorized gradient code automatically when the size of the 
problem is variable, but the example may serve to incite some 
imaginative coders to action.


Thanks again Gabor.

JN

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


[Rd] How can I catch errors thrown from c via the Rcpp error() function?

2009-04-15 Thread Kieran O'Neill

Hi

I am using the flowClust package from BioConductor, which is largely 
implemented in c. For some of my data, the package occasionally (and 
quite stochastically) encounters a particular condition which halts its 
operation. At this point, it calls the error() function defined by Rcpp, 
and halts.


What I would like to be able to do is to catch the error thrown, and 
retry the operation a few times before giving up.


However, when I wrap the call to flowClust in try() or tryCatch(), the 
error seems to completely bypass them:


Examples:

1. This is a trivial example just to test the try() function, and 
correctly assigns the error to the variable x:


> x <- try(stop(simpleError('blah')))
Error : blah
> x
[1] "Error : blah\n"
attr(,"class")
[1] "try-error"

2. This is an example using flowClust (using real data, set up to 
guarantee that the error is thrown):


> x <- try(res30 = flowClust(tFrame, K=30, B=1000, varNames=c('CD4', 
'CD8','KI67', 'CD45RO', 'CD28', 'CD57', 'CCR5', 'CD19', 'CD27', 'CCR7', 
'CD127')))

Error in flowClust(tFrame, K = 30, B = 1000, varNames = c("CD4", "CD8",  :

The covariance matrix is near singular!
Try running the program with a different initial configuration or less 
clusters

> x
Error: object "x" not found


The c code throwing the error is as follows (from flowClust.c):

if(status!=0)
  {
  error("\n The covariance matrix is near singular! \n Try running 
the program with a different initial configuration or less clusters 
\n");  }



I looked up the error() function in Writing R Extensions  and it states: 
"The basic error handling routines are the equivalents of stop and 
warning in R code, and use the same interface."


Yet, it seems that they are not caught by R's error handling code.

So:

1. Is this the general case (that Rcpp error()s are not handled by try() 
and related methods in R)? (I'm sure this could be tested with a trivial 
example, but I'm not yet familiar enough with wrapping c code in R to do 
so.)


2. If so, what is the correct way to handle them in R?

3. If not, do you have any suggestions as to what may have caused 
flowClust to behave in this way? (So that I can contact the package 
maintainers and report the bug.)


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


Re: [Rd] How can I catch errors thrown from c via the Rcpp error() function?

2009-04-15 Thread Dirk Eddelbuettel

Kieran,

On 15 April 2009 at 18:03, Kieran O'Neill wrote:
| I am using the flowClust package from BioConductor, which is largely 
| implemented in c. For some of my data, the package occasionally (and 
| quite stochastically) encounters a particular condition which halts its 
| operation. At this point, it calls the error() function defined by Rcpp, 
| and halts.
| 
| What I would like to be able to do is to catch the error thrown, and 
| retry the operation a few times before giving up.
| 
| However, when I wrap the call to flowClust in try() or tryCatch(), the 
| error seems to completely bypass them:
| 
| Examples:
| 
| 1. This is a trivial example just to test the try() function, and 
| correctly assigns the error to the variable x:
| 
|  > x <- try(stop(simpleError('blah')))
| Error : blah
|  > x
| [1] "Error : blah\n"
| attr(,"class")
| [1] "try-error"
| 
| 2. This is an example using flowClust (using real data, set up to 
| guarantee that the error is thrown):
| 
|  > x <- try(res30 = flowClust(tFrame, K=30, B=1000, varNames=c('CD4', 
| 'CD8','KI67', 'CD45RO', 'CD28', 'CD57', 'CCR5', 'CD19', 'CD27', 'CCR7', 
| 'CD127')))
| Error in flowClust(tFrame, K = 30, B = 1000, varNames = c("CD4", "CD8",  :
| 
| The covariance matrix is near singular!
| Try running the program with a different initial configuration or less 
| clusters
|  > x
| Error: object "x" not found
| 
| 
| The c code throwing the error is as follows (from flowClust.c):
| 
| if(status!=0)
|{
|error("\n The covariance matrix is near singular! \n Try running 
| the program with a different initial configuration or less clusters 
| \n");  }
| 
| 
| I looked up the error() function in Writing R Extensions  and it states: 
| "The basic error handling routines are the equivalents of stop and 
| warning in R code, and use the same interface."
| 
| Yet, it seems that they are not caught by R's error handling code.
| 
| So:
| 
| 1. Is this the general case (that Rcpp error()s are not handled by try() 
| and related methods in R)? (I'm sure this could be tested with a trivial 
| example, but I'm not yet familiar enough with wrapping c code in R to do 
| so.)

Allow me to take the narrow view here as Rcpp maintainer.  What you can do
with Rcpp is to provide a C++ layer of try/catch around inner code which may
throw C++ exception.  This will usually be caught, and (as shown in the Rcpp
docs and examples) we can pass the exception message back up to R as a
regular error message.  This is very useful as it gives you control back at
the R prompt rather than just going belly-up.

Now, R's try() and tryCatch() are completely separate and not tied into the
exception mechanism Rcpp deals with, which is at a much lower level. 

Likewise, you may be out of luck with flowClust if it is C program.  You
could try to add a C++ layer that tried to catch error and allows you do
continue your loops.  I did something like that 15 years ago in my
dissertation research to ensure I survived the occassional numerical error
from Fortran during longer Monte Carlo runs,

| 2. If so, what is the correct way to handle them in R?

Tricky. See 1. :)

| 3. If not, do you have any suggestions as to what may have caused 
| flowClust to behave in this way? (So that I can contact the package 
| maintainers and report the bug.)

You could always contact them anyway and ask for advice.

Hth,  Dirk

-- 
Three out of two people have difficulties with fractions.

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