[Rd] 'ecdf': how about exploiting property that 'x' is sorted?

2013-02-05 Thread Suharto Anggono Suharto Anggono
In the code of function 'ecdf' di R (for example, version 2.15.2), input 'x' is 
sorted first. Because the values are sorted, same values are contiguous. So, 
how about using an approach as inside function 'rle'? Because missing values is 
removed by 'sort', it can be done like this.

i <- c(which(x[-1L] != x[-n]), n)
rval <- approxfun(x[i], i/n, ...)

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


Re: [Rd] Error building R from SVN - unable to run 'pdflatex' on 'example-1.tex'

2013-02-05 Thread Jonathon Love

yup. that fixed it. thanks for your help.

there are a handful of extra files in the source tarball (some pdfs, 
etc.), that aren't in the SVN. it appears that building these requires a 
bunch more stuff installed, and that's why building the source tarball 
worked, but not the SVN contents.


with thanks

Jonathon




On 5 February 2013 at 01:27, Jonathon Love wrote:
| On 04/02/13 23:47, Duncan Murdoch wrote:
|  > Probably, but if you want help you're going to need to give some more
|  > information first, such as what exactly you installed from SVN, what OS
|  > you are using, what target you tried to build, and anything else
|  > necessary so that a potential helper can duplicate what you did.
|
| my bad. sorry.
|
| on ubuntu 12.10 i did a checkout of the 2.15.2 tag

Try this:

sudo apt-get build-dep r-base

which will install what the distro itself uses to build the package.

Also look into './configure --help' to learn about different aspects of the
build which you can turn on or off.  I keep a little shell script with my
prefered configuration to create a local build of r-devel from SVN.

Dirk



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


[Rd] Money

2013-02-05 Thread ivo welch
ladies and gents---is there a list of what the R core team would like
to get funded?  let's presume that we could raise $100,000 or
$1,000,000 (or even $10,000,000) for the core team.  what would the R
core team do with the money?  is there a list somewhere, perhaps like
kickstarter?

my preference would be improving up the default error hunting
process---from greater strictness to assertions to line numbers on
errors, followed by a POD.  I know there are many clever ways to go
about every one of these issues in R, but they are not so "standard"
and built into the core language that every beginning R student will
benefit.

/iaw

Ivo Welch (ivo.we...@gmail.com)

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


[Rd] How to use summary.mer inside a package?

2013-02-05 Thread Benjamin Hofner
I have a question regarding the build of my project papeR (hosted on 
R-forge http://r-forge.r-project.org/R/?group_id=1574) with respect to 
lme4.


Both, Windows and MacOS are complaining that lme4 doesn't export summary:

  Error : object 'summary' is not exported by 'namespace:lme4'
  ERROR: lazy loading failed for package 'papeR'

Linux however builds the project as desired.

I now did check my package using Uwe Ligges' winbuilder project and got 
positive results i.e. no errors for Windows there. See (for the next 72 
hours):


http://win-builder.r-project.org/y3uwwx93nJ92
http://win-builder.r-project.org/10mtpspKx7us

Can anyone tell me why this happens (only on R-forge and only for 
certain systems) and how to prevent this?


[I already asked the R-forge maintainers and was redirected to the 
general R mailing lists]


As a side note: The reason for importing lme4's summary is that 
otherwise my function summary.fixef, which extracts fixed effects from 
nlme and lme4 models for printing e.g. in reports, doesn't use/find 
summary.mer on "mer" objects -- even if lme4 is loaded earlier. On the 
other hand, lme models (from package nlme) are handled correctly despite 
the fact that I do not import the corresponding summary function.


Thank you very much
  Benjamin

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


Re: [Rd] setGeneric() gives "must supply skeleton" when checking package

2013-02-05 Thread Tim Bergsma
Martin,

I added "importFrom(reshape, cast)" to NAMESPACE; package now survives R
CMD check.

Thanks for your help!

-Tim


On Sun, Feb 3, 2013 at 12:36 PM, Martin Morgan  wrote:

> On 02/02/2013 02:34 PM, Tim Bergsma wrote:
>
>> r-devel,
>>
>> In a development version of the CRAN package metrumrg, I write ...
>>
>> require(reshape)
>> setGeneric('cast')
>> setOldClass(c('keyed','data.**frame'))
>> setMethod('cast','keyed', function ...)
>>
>> The result is satisfactory when sourcing the code directly, but when
>> checking the package (which has 'reshape' as a dependency in the
>> DESCRIPTION file) I get the following:
>>
>> "Error in setGeneric("cast") : must supply a function skeleton for
>> ???cast???, explicitly or via an existing function."
>>
>
> You haven't mentioned your DESCRIPTION or NAMEPSACE file, but the right
> thing to do is
>
> DESCRIPTION:
>
> Depends: reshape
>
> NAMESPACE:
>
> importFrom(reshape, cast)
>
> R/somefile.R:
>
> setGeneric("cast")
>
> Perhaps your current setGeneric is being performed inside the namespace
> when cast is not yet available (e.g., because it has not been imported)?
>
> Martin Morgan
>
>
>> The help for setGeneric() seems to suggest that no function skeleton is
>> needed  when creating a generic for a function defined in some other
>> package.  I found one or two previous related posts, but no obvious
>> resolution.
>>
>> Comments appreciated,
>>
>> Tim Bergsma, PhD
>>
>> [[alternative HTML version deleted]]
>>
>> __**
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-devel
>>
>>
>
> --
> Computational Biology / Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N.
> PO Box 19024 Seattle, WA 98109
>
> Location: Arnold Building M1 B861
> Phone: (206) 667-2793
>

[[alternative HTML version deleted]]

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


Re: [Rd] best practice for packages using mclapply to avoid tcltk

2013-02-05 Thread Paul Johnson
On Sun, Feb 3, 2013 at 1:34 PM, Simon Urbanek
 wrote:
> As Peter pointed out earlier, this is better addressed by disabling the 
> Tcl/Tk event loop in forked processes.
>
Dear Simon:

I don't understand.  Can you please try to say it again?

I find Peter's comment (on Jan 3, 2013, thread title: weird bug with
parallel, RSQlite and tcltk):

"More likely, the wisdom of calling R_ProcessEvents and R_PolledEvents
in parallel processes should be questioned. I tend to think that they
should both be disabled completely conditionally on R_isForkedChild.
At least in the Tk loop, some of the events are generated as responses
to specific queries, and having one process ask for something and
another one handling the reply, leaving the first one waiting
indefinitely, is just Not Right."

That suggested to me the problem is in R itself, or the tcltk package

If package writers don't follow my suggestion, what do they think they
should do  instead?

pj
> Cheers,
> Simon
>
> On Feb 2, 2013, at 5:02 PM, Paul Johnson wrote:
>
>> Dear R-devel friends:
>>
>> I'm back to bother you again about the conflict between mclapply and
>> tcltk. I've been
>> monitoring several packages that want to use mclapply to parallelize
>> computations and
>> need to figure out what should be done.
>>
>> It appears tcltk cannot be safely unloaded, so the best we can do is
>> check for the presence of tcltk and stop if it is found before
>> mclapply() is used.
>>
>> I wish you would please review my suggestion below.  Maybe checkForTcltk()
>> could be used in the parallel package. Otherwise, we are letting
>> people run with scissors.
>>
>> There's a warning about this in ?mclapply
>>
>> It is _strongly discouraged_ to use these functions in GUI or
>>embedded environments, because it leads to several processes
>>sharing the same GUI which will likely cause chaos (and possibly
>>crashes).  Child processes should never use on-screen graphics
>>devices.(Warning in ?mclapply)
>>
>> Bug report: (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15040 )
>>
>> By the way, what is "embedded environments" in ?mclapply
>>
>> ## I don't want to crash your system, but if you want to see a freeze-up:
>> ## change 0 to 1 and run this:
>> if (0){
>> library(parallel)
>> library(tcltk)
>> example(mclapply)
>> }
>>
>> ## What are packagers supposed to do if they want to call mclapply?
>> ## It appears to me the best a package can do is scan for tcltk and
>> ## stop. Here's a function that does so.
>>
>> checkForTcltk <- function(){
>>if ("tcltk" %in% loadedNamespaces()){
>>stop("This function cannot be used because the R tcltk
>>package is loaded. It is necessary to Close R, and re-run
>>the program making sure that tcltk is never loaded before
>>this function is called.")
>>}
>> }
>>
>> ## put that to use.
>> MCLApply <- function(){
>>if (!require(parallel)) stop ("parallel wouldn't load")
>>checkForTcltk()
>>example(mclapply)
>> }
>>
>> ## test that:
>>
>> checkForTcltk()
>> MCLApply()
>>
>> library(tcltk)
>> checkForTcltk()
>>
>>
>> ## Why can't tcltk just be unloaded? I don't understand, but it is a deep
>> ## problem.
>>
>> ## Consider the ominous warnings in R detach's help:
>> ##
>> ## "Unloading some namespaces has undesirable side effects: e.g.
>> ##  unloading ‘grid’ closes all graphics devices, and on most systems
>> ##  ‘tcltk’ cannot be reloaded once it has been unloaded and may crash
>> ##  R if this is attempted." (Note: section of ?detach).
>> ##
>> ## To be fair, that does not say unloading tcltk is fatal, but
>> ## reloading it is fatal. And I've seen plenty of times when
>> ## unloading it is fatal.
>>
>> ## Example 1. Crash on library.dynam.unload()
>> detach("package:tcltk", unload = TRUE)
>> library.dynam.unload("tcltk", system.file(package = "tcltk"))
>>
>> ## Output
>> ## > library.dynam.unload("tcltk", system.file(package = "tcltk"))
>> ## >
>> ##  *** caught segfault ***
>> ## address 0x7f69c9d99580, cause 'memory not mapped'
>>
>> ## Possible actions:
>> ## 1: abort (with core dump, if enabled)
>> ## 2: normal R exit
>> ## 3: exit R without saving workspace
>> ## 4: exit R saving workspace
>> ## Selection:
>> ## Process R segmentation fault at Sat Feb  2 13:55:08 2013
>>
>>
>> ## Example 2.
>> library(tcltk)
>> detach("package:tcltk", unload = TRUE)
>> library.dynam.unload("tcltk", system.file(package = "tcltk"))
>> example(mclapply)
>>
>> ## Output:
>>
>> ## > example(mclapply)
>>
>> ##  *** caught segfault ***
>> ## address 0x7f25ccbfe000, cause 'memory not mapped'
>>
>> ## Possible actions:
>> ## 1: abort (with core dump, if enabled)
>> ## 2: normal R exit
>> ## 3: exit R without saving workspace
>> ## 4: exit R saving workspace
>> ## Selection:
>>
>>
>> pj
>>
>> --
>> Paul E. Johnson
>> Professor, Political Science  Assoc. Director
>> 1541 Lilac Lane, Room 504  Center for Research Methods
>> University of Kansas University of Kansas
>> http://pj.freef