peter dalgaard | 1 Sep 2010 13:50
Picon

Re: R and Epi Info


On Aug 31, 2010, at 10:16 PM, Sullivan, Kevin M wrote:

> Hello,
>   I was wondering who to contact to see about somehow interconnecting or integrating the programs R and Epi
Info.  

Well, first of all there is a mailing list, R-sig-epi <at> lists.r-project.org. It is not very active, but I
know that at least some of the regulars are familiar with Epi Info and the list includes the authors of
several R packages for epidemiology.

--

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes <at> cbs.dk  Priv: PDalgd <at> gmail.com

Olaf Mersmann | 1 Sep 2010 14:06
Picon
Favicon

Speed improvement for Find() and Position()

Dear R-developers,

both Find() and Position() (as the documentation mentions) are currently not optimized in any way. I have
rewritten both functions in a more efficient manner by replacing the sapply() with a for() loop that
terminates early if a match is found. Here is a patch against the current subversion HEAD

  http://www.statistik.tu-dortmund.de/~olafm/temp/fp.patch

and here are some numbers to show that this change is worth while:

% cat fp_bench.R 
set.seed(42)
pred <- function(z) z == 1

for (n in c(10^(2:4))) {
  x <- sample(1:n, 2*n, replace=TRUE)

  tf <- system.time(replicate(1000L, Find(pred, x)))
  message(sprintf("Find    : n=%5i user=%6.3f system=%6.3f",
                  2*n, tf[1], tf[2]))

  tp <- system.time(replicate(1000L, Find(pred, x)))
  message(sprintf("Position: n=%5i user=%6.3f system=%6.3f",
                  2*n, tp[1], tp[2]))
}

## Unpatched R:
% Rscript fp_bench.R 
Find    : n=  200 user= 0.491 system= 0.015
Position: n=  200 user= 0.477 system= 0.014
(Continue reading)

Christophe Rhodes | 1 Sep 2010 15:27
Favicon

Re: introspective capabilities

Duncan Murdoch <murdoch.duncan <at> gmail.com> writes:

> On 27/08/2010 7:52 AM, Christophe Rhodes wrote:
>> Hi,
>>
>> Is there any way, from R code, to perform introspection as to where
>> certain names acquired their values?
>
> There's the "keep.source" option to source() and the optional
> "srcfile" argument to parse() that tell R to keep this information.
> If you haven't changed the default
> getOption("keep.source") from TRUE, then source will default to
> keeping it, and you can find the original location of a function
> definition for function f by looking in attr(body(f), "srcref").  See
> ?srcref for the format; there aren't a lot of user-level utility
> functions for working with this.

Thanks.  This is enough for my immediate purposes: supporting
single-keystroke (M-.) jumping to source locations of functions.

> For packages, the relevant option is "keep.source.pkgs" at the time
> the package is installed.

Thank you.

Is there anything like a cross-referencing database within R?  The
functionality I'm looking for here is to be able to name a function, and
come back with a list of functions (or srcrefs) where that name is
used.  (I realise that this is not in general possible; just the
lexically-apparent cases would be enough).
(Continue reading)

Duncan Murdoch | 1 Sep 2010 15:59
Picon

Re: introspective capabilities

On 01/09/2010 9:27 AM, Christophe Rhodes wrote:
> Duncan Murdoch <murdoch.duncan <at> gmail.com> writes:
>
> > On 27/08/2010 7:52 AM, Christophe Rhodes wrote:
> >> Hi,
> >>
> >> Is there any way, from R code, to perform introspection as to where
> >> certain names acquired their values?
> >
> > There's the "keep.source" option to source() and the optional
> > "srcfile" argument to parse() that tell R to keep this information.
> > If you haven't changed the default
> > getOption("keep.source") from TRUE, then source will default to
> > keeping it, and you can find the original location of a function
> > definition for function f by looking in attr(body(f), "srcref").  See
> > ?srcref for the format; there aren't a lot of user-level utility
> > functions for working with this.
>
> Thanks.  This is enough for my immediate purposes: supporting
> single-keystroke (M-.) jumping to source locations of functions.
>
> > For packages, the relevant option is "keep.source.pkgs" at the time
> > the package is installed.
>
> Thank you.
>
> Is there anything like a cross-referencing database within R?  The
> functionality I'm looking for here is to be able to name a function, and
> come back with a list of functions (or srcrefs) where that name is
> used.  (I realise that this is not in general possible; just the
(Continue reading)

Hadley Wickham | 1 Sep 2010 17:38
Favicon
Gravatar

S3 method for package listed in suggest/enhance

Hi all,

The profr package provides a method for displaying its output with
ggplot: ggplot.print.  You don't need this ggplot2 to use profr, so
ggplot2 is listed under enhances in the DESCRIPTION file.

If I have just S3method(ggplot, profr) in my NAMESPACE, then I get:

** testing if installed package can be loaded
Error : object 'ggplot' not found whilst loading namespace 'profr'
ERROR: loading failed

If I have both S3method(ggplot, profr) and importFrom(ggplot2,
ggplot), then I get:

* checking package dependencies ... ERROR
Namespace dependency not required: ggplot2

What's the correct way of exporting an S3 method for a generic in a
suggested package?

Thanks,

Hadley

--

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

(Continue reading)

Adrian Waddell | 1 Sep 2010 18:16
Picon

Installing a Tcl/Tk Extension on OSX

Dear R-Community,

I need the Img tk extension for my R package. It all works on my Ubuntu
machine (libtk-img). However I experience a great deal of trouble when I
try to install the package on OSX 10.5 or 10.6 (in fact I'm not able to
do it).

As I understand it, the ActiveTcl with it's teacup package manager do
not have an effect on the the x11 tcl installation which R accesses.
MacPorts however has the libtk-img package not listed and compiling it
from the source (with configure, make all, make install) does not do the
job either for me (adding the compiled package folder to auto_path).

Now, as I would like some R users to once use my R package (once it's on
CRAN), installing the Img tk extension should to be a fairly easy task
on OSX .

Can anybody tell me how I best tackle this problem in a way, such that
OSX R users (and myself) in future can easily install the Img tk package?

Sincerely,

Adrian Waddell

Kjetil Halvorsen | 2 Sep 2010 00:22
Picon

Looks like a bug in subsetting of a complicated object

I don't understand what is happening! I have a (large) object sim1, an
matrix list
with dim c(101,101) where each element is an 3*3 matrix. I am
subsetting that with
a matrix coo, of dim c(100,2), of unique indices, but the resulting object
has length 99, not 100 as expected.

Code reproducing the problem follows:

library(RandomFields)

set.seed(123)
sim0 <- GaussRF(x=seq(0, 100, by=1),
                y=seq(0, 100, by=1),
                grid=TRUE, model="spherical",
                param=c(0, 1, 0, 10), trend=NULL, n=9, gridtriple=FALSE)

simmatrices <- function(arr) # arr must be an array of rank 3
                        {
               d <- dim(arr)
               n1 <- d[1]; n2 <- d[2] # we suppose d[3]==9
               res <- vector(length=n1*n2, mode="list")
               dim(res) <- c(n1, n2)
               for (i in 1:n1) for (j in 1:n2) {
                 x1 <- arr[i, j, 1:3];x2 <- arr[i, j, 4:6]
                 x3 <- arr[i, j, 7:9]
                 res[[i, j]] <- x1%o%x1 + x2%o%x2 + x3%o%x3
               }
               res
             }
(Continue reading)

Mark.Bravington | 2 Sep 2010 05:01
Picon
Picon
Favicon

Re: introspective capabilities

Hi Christophe

You could also look at the 'foodweb' function in package 'mvbutils'-- and specifically 'callers.of'. It
should do just what you want, though you do have to tell it which environments to search through.

bye
Mark

-- 
Mark Bravington
CSIRO Mathematical & Information Sciences
Marine Laboratory
Castray Esplanade
Hobart 7001
TAS

ph (+61) 3 6232 5118
fax (+61) 3 6232 5012
mob (+61) 438 315 623

Christophe Rhodes wrote:
> Duncan Murdoch <murdoch.duncan <at> gmail.com> writes:
> 
>> On 27/08/2010 7:52 AM, Christophe Rhodes wrote:
>>> Hi,
>>> 
>>> Is there any way, from R code, to perform introspection as to where
>>> certain names acquired their values?
>> 
>> There's the "keep.source" option to source() and the optional
(Continue reading)

Peter Ehlers | 2 Sep 2010 07:22
Picon
Favicon

Re: Looks like a bug in subsetting of a complicated object

On 2010-09-01 16:22, Kjetil Halvorsen wrote:
> I don't understand what is happening! I have a (large) object sim1, an
> matrix list
> with dim c(101,101) where each element is an 3*3 matrix. I am
> subsetting that with
> a matrix coo, of dim c(100,2), of unique indices, but the resulting object
> has length 99, not 100 as expected.
>
> Code reproducing the problem follows:
>
>
> library(RandomFields)
>
> set.seed(123)
> sim0<- GaussRF(x=seq(0, 100, by=1),
>                  y=seq(0, 100, by=1),
>                  grid=TRUE, model="spherical",
>                  param=c(0, 1, 0, 10), trend=NULL, n=9, gridtriple=FALSE)
>
> simmatrices<- function(arr) # arr must be an array of rank 3
>                          {
>                 d<- dim(arr)
>                 n1<- d[1]; n2<- d[2] # we suppose d[3]==9
>                 res<- vector(length=n1*n2, mode="list")
>                 dim(res)<- c(n1, n2)
>                 for (i in 1:n1) for (j in 1:n2) {
>                   x1<- arr[i, j, 1:3];x2<- arr[i, j, 4:6]
>                   x3<- arr[i, j, 7:9]
>                   res[[i, j]]<- x1%o%x1 + x2%o%x2 + x3%o%x3
>                 }
(Continue reading)

Philippe Grosjean | 2 Sep 2010 11:01

Re: Installing a Tcl/Tk Extension on OSX

This is relatively simple if you can find the packages you need in the 
default Tcl/Tk install on the Mac (/System/Library/Tcl) and if these 
packages are compatibles with the X11 Tcl/Tk used by R. This should be 
fine for packages containing no compiled code. For the others, you 
should check first (but for instance, Img and tsl work for me - Mac OS X 
10.6.4). You can then use these package in R own Tcl environment like this:

 > library(tcltk)
Loading Tcl/Tk interface ... done
 > addTclPath("/System/Library/Tcl")
 > tclRequire("Img")
<Tcl> 1.4

Best,

Philippe

..............................................<°}))><........
  ) ) ) ) )
( ( ( ( (    Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (    Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons University, Belgium
( ( ( ( (
..............................................................

On 01/09/10 18:16, Adrian Waddell wrote:
> Dear R-Community,
>
> I need the Img tk extension for my R package. It all works on my Ubuntu
(Continue reading)


Gmane