[Rd] example package for devel newcomers
Hi, I'd like to know whether there is a package (or more, of course) regarded as a good example that could be used also as an instructional tool for newcomers to R extensions development. Thanks. -- Alexandre -- Alexandre Santos Aguiar, MD, SCT signature.asc Description: This is a digitally signed message part. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] example package for devel newcomers
On 11-07-31 5:45 PM, Alexandre Aguiar wrote: Hi, I'd like to know whether there is a package (or more, of course) regarded as a good example that could be used also as an instructional tool for newcomers to R extensions development. I don't think there is a canonical one; different people prefer different programming styles. I'd suggest you find a package by an author where you understand the contents and like the style, and study that. If it involves subject matter that interests you it will be easier to understand than if it's completely new. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Front ends handling help.search() results?
On 11-07-31 10:34 AM, Thomas Friedrichsmeier wrote: On Saturday 30 July 2011, Duncan Murdoch wrote: I have not committed this code yet, because the new types of entries could mess up existing front ends and I wanted to give people some warning. I expect I'll commit (to R-devel only) within a day or two. Many thanks for the warning! I have added (untested) support for the new result types in RKWard. I've just committed the changes to R-devel. Let me know if there is anything worse than what I described. There were a lot of changes to the display of links in help.search() and related results, and it's possible I got some of them wrong. (They are tricky because we still try to support static help, but I don't have that installed and haven't tested it.) Please let me know if you come across any broken links that look like they are in base R. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] Save generic plot to file (before rendering to device)
Seems like maybe a call is missing in grid.newpage? But I think it should be called multiple times for plot.lm - there are multiple plots there. Hadley On Monday, August 1, 2011, Jeroen Ooms wrote: > Bumping this one up because the 'before.plot.new' solution turned out > to be sub-optimal after all. > >>> It should be possible to do this with a before.plot.new hook, right? >> >> Yes, sure, if you treat the first and last plot separately. > > It turns out that the before.plot.new hook does not is not triggered > at the right moments. I'm not sure if this is intended behavior or > incorrect implementation. What I was expecting is a hook/event that is > triggered every time before a new graphics frame is opened. E.g. if > there is an open PDF device and some plots are printed, the number of > times the hook is called should be exactly equal to the number of > pages in the resulting PDF document. Sometimes this works as expected, > sometimes it doesn't. > > At the end of this message some example code. In the first example, > the hook works as expected is called 4 times, as there are 4 plots. In > all the other examples the event is either triggered too often or not > triggered at all. I guess the hook is called when the plot.new() > function is explicitly called, which might not always happen. > > My question would be if (1) this is the intended behavior for > 'before.plot.new', and (2) if yes, would it be possible to define an > additional event that always triggers, and only triggers, if a > completely new graphics device is opened. I.e. whenever a pdf device > would start a new page. > > Thank you. > > > #set the hook (event listener) > setHook("before.plot.new", NULL); > setHook("before.plot.new", function(){ message("Yay! A new plot!")}); > > #works as expected: > plot(lm(speed~dist, cars), ask=F); > > #triggered way too often, once for every partition of the plot > plot(mtcars); > > #not triggered at all by lattice > library(lattice); > dotplot(speed~dist, cars); > > #not triggered at all by ggplot2 > library(ggplot2); > qplot(speed, dist, data=cars); > > -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] example package for devel newcomers
Em Segunda 01 Agosto 2011, vocĂȘ escreveu: > Is there a preferred language you would like to use in your package > development? I randomly downloaded packages until I found some that > helped me along my way, and might be able to help you pick one. If you > are just looking at building a package of R functions and data you > have developed, possibly the following example will get you started > till you feel comfortable with the "Writing R Extensions" > documentation (http://cran.r-project.org/doc/manuals/R-exts.pdf): Dan, your message is cool. Well, here is what my project is about: it is a package to embed php into R. Named Rphp for now. It is mostly done from scratch. I have loved R-exts.pdf. Great stuff. Why embed php into R? My primary purpose is to use web content management systems (WCMS) ready and extensively tested code from R cgi scripts. Someone more experienced with php might think of other uses. My approach is RAD(ical) and innovative (IMextremelyHO :-D) because: a) *any* php based WCMS can be used from R code with no php or html coding; b) output fully compliant with the website appearance; c) WCMS automatic upgrades and interfaces changes (skins or themes) will be so unlikey to cause need for maintenance in R cgi scripts; d) R cgi scripts will not demand changes in php code; e) the builtin php session support obviates the need for any special session coding by R (likely non-web) programmers; f) potential for improved analysis of web databases and even of systems surveillance tasks. During my explorations of the R interface for extensions and the time spent in this tiny project, some questions emerged. 1. my code uses no recursion but I do not really know what is inside php code. Stack size could be a concern. Has any of you there ever needed to allocate a new stack for a package? Is it better to wait for complaints (if anyone ever would like to try this package...)? 2. can R_registerRoutines be called more than once within the same library (the same DllInfo data) so that it can reconfigure itself on the fly? 3. Is it safe (I guess it is) to "re-export" a function pointer retrieved with R_GetCCallable? 4. when loading a second library (in this case libphp5.so) is it better to put it in the package library directory and load it using the 'char *path' member of DllInfo? Using a second library has implications: a) a given R setup can be limited to the user space without root access; b) in the case of desktops where someone might use Rphp, most systems do not have libphp5.so installed by default and installing it frequently means to install apache and all (many) related packages; c) many sysadmins do not have root access but can compile their own php version; d) building the libphp5.so may not be an easy task for many. 5. Similar to 3, is it safe to "export" functions of the second library? libphp5.so will not be registered to R and has some interesting functions that can be "exported" directly or as pointers within Rphp library. A stub function can be used. 6. related to 4, with the many machine architectures and operating systems around I think it is neither desirable nor feasible to distribute precompiled libphp5.so versions; the package itself can download (wget and curl are everywhere) and compile php. Compiling php is not a lengthy task (6m12.9s in my quadcore desktop) but is a lot tricky and demands several development packages not installed by default in desktop systems. Their installations would require root access. What is the suggested approach to deploy libphp5.so? 7. I do not know how to produce a version for windows if requested. I have only an old MSC++ 97 and lcc (current) and have xp in a virtual box. This concern includes php. Can I get help regarding windows in this list? It might mean actual work: adapting code, compiling, packaging, etc. Not sure what is needed. 8. system safety does not seem a concern regarding this use of php, but... Any suggestions? I guess some manual steps will be necessary because of potential security breaches related to the use of a second library. Patching php to produce a special build to be used as the package library would not be a trivial task and would demand updates at every new php version. Something I can't assure I can do. And would have to distribute the whole php source code: still have to study php licensing scheme. BTW, I copied Rdynpriv.h by hand to my include path to get access to 'struct _DllInfo' definition. The R install process did not copy this file. Am I doing something wrong here? Sorry for the lengthy message. Thanx for your help. -- Alexandre -- Alexandre Santos Aguiar, MD, SCT signature.asc Description: This is a digitally signed message part. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel