Re: [Rd] [EXTERNAL] Re: NOTE: multiple local function definitions for ?fun? with different formal arguments

2024-02-06 Thread Izmirlian, Grant (NIH/NCI) [E] via R-devel
Because functions get called and therefore, the calling sequence matters. It’s 
just protecting you from yourself, but as someone pointed out, there’s a way to 
silence such notes.
G


From: Hervé Pagès 
Sent: Tuesday, February 6, 2024 2:40 PM
To: Izmirlian, Grant (NIH/NCI) [E] ; Duncan Murdoch 
; r-devel@r-project.org
Subject: Re: [EXTERNAL] Re: [Rd] NOTE: multiple local function definitions for 
?fun? with different formal arguments


On 2/6/24 11:19, Izmirlian, Grant (NIH/NCI) [E] wrote:
The note refers to the fact that the function named ‘fun’ appears to be defined 
in two different ways.

Sure I get that. But how is that any different from a variable being defined in 
two different ways like in

if (mode == 1)
x <- -8
else
x <- 55

This is such a common and perfectly fine pattern. Why would this be considered 
a potential hazard when the variable is a function?

H.

From: Hervé Pagès 
<mailto:hpages.on.git...@gmail.com>
Sent: Tuesday, February 6, 2024 2:17 PM
To: Duncan Murdoch <mailto:murdoch.dun...@gmail.com>; 
Izmirlian, Grant (NIH/NCI) [E] 
<mailto:izmir...@mail.nih.gov>; 
r-devel@r-project.org<mailto:r-devel@r-project.org>
Subject: [EXTERNAL] Re: [Rd] NOTE: multiple local function definitions for 
?fun? with different formal arguments


Thanks. Workarounds are interesting but... what's the point of the NOTE in the 
first place?

H.
On 2/4/24 09:07, Duncan Murdoch wrote:
On 04/02/2024 10:55 a.m., Izmirlian, Grant (NIH/NCI) [E] via R-devel wrote:


Well you can see that yeast is exactly weekday you have.  The way out is to 
just not name the result

I think something happened to your explanation...




toto <- function(mode)
{
 ifelse(mode == 1,
 function(a,b) a*b,
 function(u, v, w) (u + v) / w)
}

It's a bad idea to use ifelse() when you really want if() ... else ... .  In 
this case it works, but it doesn't always.  So the workaround should be


toto <- function(mode)
{
if(mode == 1)
function(a,b) a*b
else
function(u, v, w) (u + v) / w
}







From: Grant Izmirlian <mailto:izmirlidr...@gmail.com>
Date: Sun, Feb 4, 2024, 10:44 AM
To: "Izmirlian, Grant (NIH/NCI) [E]" 
<mailto:izmir...@mail.nih.gov>
Subject: Fwd: [EXTERNAL] R-devel Digest, Vol 252, Issue 2

Hi,

I just ran into this 'R CMD check' NOTE for the first time:

* checking R code for possible problems ... NOTE
toto: multiple local function definitions for �fun� with different
   formal arguments

The "offending" code is something like this (simplified from the real code):

toto <- function(mode)
{
 if (mode == 1)
 fun <- function(a, b) a*b
 else
 fun <- function(u, v, w) (u + v) / w
 fun
}

Is that NOTE really intended? Hard to see why this code would be
considered "wrong".

I know it's just a NOTE but still...

I agree it's a false positive, but the issue is that you have a function object 
in your function which can't be called unconditionally.  The workaround doesn't 
create such an object.

Recognizing that your function never tries to call fun requires global 
inspection of toto(), and most of the checks are based on local inspection.

Duncan Murdoch

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

--

Hervé Pagès



Bioconductor Core Team

hpages.on.git...@gmail.com<mailto:hpages.on.git...@gmail.com>
CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and are confident the 
content is safe.


--

Hervé Pagès



Bioconductor Core Team

hpages.on.git...@gmail.com<mailto:hpages.on.git...@gmail.com>
CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and are confident the 
content is safe.


[[alternative HTML version deleted]]

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


Re: [Rd] [EXTERNAL] Re: NOTE: multiple local function definitions for ?fun? with different formal arguments

2024-02-06 Thread Izmirlian, Grant (NIH/NCI) [E] via R-devel
The note refers to the fact that the function named ‘fun’ appears to be defined 
in two different ways.

From: Hervé Pagès 
Sent: Tuesday, February 6, 2024 2:17 PM
To: Duncan Murdoch ; Izmirlian, Grant (NIH/NCI) [E] 
; r-devel@r-project.org
Subject: [EXTERNAL] Re: [Rd] NOTE: multiple local function definitions for 
?fun? with different formal arguments


Thanks. Workarounds are interesting but... what's the point of the NOTE in the 
first place?

H.
On 2/4/24 09:07, Duncan Murdoch wrote:
On 04/02/2024 10:55 a.m., Izmirlian, Grant (NIH/NCI) [E] via R-devel wrote:

Well you can see that yeast is exactly weekday you have.  The way out is to 
just not name the result

I think something happened to your explanation...



toto <- function(mode)
{
 ifelse(mode == 1,
 function(a,b) a*b,
 function(u, v, w) (u + v) / w)
}

It's a bad idea to use ifelse() when you really want if() ... else ... .  In 
this case it works, but it doesn't always.  So the workaround should be


toto <- function(mode)
{
if(mode == 1)
function(a,b) a*b
else
function(u, v, w) (u + v) / w
}






From: Grant Izmirlian <mailto:izmirlidr...@gmail.com>
Date: Sun, Feb 4, 2024, 10:44 AM
To: "Izmirlian, Grant (NIH/NCI) [E]" 
<mailto:izmir...@mail.nih.gov>
Subject: Fwd: [EXTERNAL] R-devel Digest, Vol 252, Issue 2

Hi,

I just ran into this 'R CMD check' NOTE for the first time:

* checking R code for possible problems ... NOTE
toto: multiple local function definitions for �fun� with different
   formal arguments

The "offending" code is something like this (simplified from the real code):

toto <- function(mode)
{
 if (mode == 1)
 fun <- function(a, b) a*b
 else
 fun <- function(u, v, w) (u + v) / w
 fun
}

Is that NOTE really intended? Hard to see why this code would be
considered "wrong".

I know it's just a NOTE but still...

I agree it's a false positive, but the issue is that you have a function object 
in your function which can't be called unconditionally.  The workaround doesn't 
create such an object.

Recognizing that your function never tries to call fun requires global 
inspection of toto(), and most of the checks are based on local inspection.

Duncan Murdoch

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

--

Hervé Pagès



Bioconductor Core Team

hpages.on.git...@gmail.com<mailto:hpages.on.git...@gmail.com>
CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and are confident the 
content is safe.


[[alternative HTML version deleted]]

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


[Rd] NOTE: multiple local function definitions for ?fun? with different formal arguments

2024-02-04 Thread Izmirlian, Grant (NIH/NCI) [E] via R-devel
Well you can see that yeast is exactly weekday you have.  The way out is to 
just not name the result

toto <- function(mode)
{
ifelse(mode == 1,
function(a,b) a*b,
function(u, v, w) (u + v) / w)
}



From: Grant Izmirlian 
Date: Sun, Feb 4, 2024, 10:44 AM
To: "Izmirlian, Grant (NIH/NCI) [E]" 
Subject: Fwd: [EXTERNAL] R-devel Digest, Vol 252, Issue 2

Hi,

I just ran into this 'R CMD check' NOTE for the first time:

* checking R code for possible problems ... NOTE
toto: multiple local function definitions for �fun� with different
  formal arguments

The "offending" code is something like this (simplified from the real code):

toto <- function(mode)
{
if (mode == 1)
fun <- function(a, b) a*b
else
fun <- function(u, v, w) (u + v) / w
fun
}

Is that NOTE really intended? Hard to see why this code would be
considered "wrong".

I know it's just a NOTE but still...

Thanks,

H.

--
Herv� Pag�s

Bioconductor Core Team
hpages.on.git...@gmail.com<mailto:hpages.on.git...@gmail.com>


CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and are confident the 
content is safe.


[[alternative HTML version deleted]]

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


[Rd] xxx not available for .C in package yyy

2016-06-20 Thread Izmirlian, Grant (NIH/NCI) [E]
Hi R package developers. This is literally the strangest thing I've ever seen.
Latest (as of a month ago) R under cygwin64.  I'm teaching an intern package
building and using the .C interface.  The package compiles, but when it gets
to "setting up lazy load" or some such it throws the error "triang" not 
available for .C()
in package "randpkg".  Upon checking, after removing the current version of the 
package
incrementing the package number just to make sure, commenting out the portion 
of the
R code that calls .C(), then building, INSTALLING again, this time works. We 
are able
to call .C("trian", ...) by hand inside of R, but then when we uncomment out 
the call
in the .R file, it throws the error again. We've even retyped that portion of 
code, we've
even dos2unix 'd everything.  Any thoughts?


Grant Izmirlian, Ph.D.
Mathematical Statistician
izmir...@mail.nih.gov

Delivery Address:
9609 Medical Center Dr, RM 5E130
Rockville MD 20850

Postal Address:
BG 9609 RM 5E130 MSC 9789
9609 Medical Center Dr
Bethesda, MD 20892-9789

 ofc:  240-276-7025
 cell: 240-888-7367
  fax: 240-276-7845


[[alternative HTML version deleted]]

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


[Rd] can someone help me understand LAM/MPI and Rmpi for use on a cluster

2005-12-23 Thread Izmirlian, Grant \(NIH/NCI\) [E]
I'm fairly astute at C and R but new to parallelization. Would someone
be willing to provide help in the form of a simple example that parallelizes
an R function from the inside of a C routine?

If so, write me back at [EMAIL PROTECTED]

Thanks!

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


[Rd] segfault following a detach

2005-12-09 Thread Izmirlian, Grant \(NIH/NCI\) [E]
Jim:

This reminds me of problems I've had before, but usually they occur when I quit 
R
i.e. q(), because when testing and developing I can't remember actually 
detaching
a package. I can however think of countless times I get a segmentation fault 
upon 
quiting R. Usually this boils down to a hidden return argumen that is given an
insufficient allocation of memory. For example

  "foo" <- function(x, y, z){
 nx <- length(x)
 ny <- length(y)
 nz <- length(z)
 ans <- .C("bar",
x = as.double(x),
y = as.double(y),
z = as.double(z),
res1 = as.double(rep(0, nx)),
res2 = as.double(rep(0, nx*ny)),
PACKAGE = "FooBar")
 list(result = asn$res1)
}

Notice that only ans$res1 is returned so that it is easy to forget about 
ans$res2, 
as I have often done! Now suppose that the C routine actually needs nx*ny*nz 
space 
(say) for the pointer to double at the position indicated by res2 instead of 
just 
the nx*ny provided. Although you would expect a segmentation fault at runtime, 
it 
is my experience that sometimes the function completes and the segmentation 
fault 
doesn't happen until I quit R.

I hope that these comments are helpful,

Grant Izmirlian,
NCI

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


[Rd] an Update on the "Woods" package--classification and constrained L1 regression for binary response

2005-12-09 Thread Izmirlian, Grant \(NIH/NCI\) [E]
Hello R-devel:

This is an update on my R package, "woods" that does bagged classification trees
using data structures in C. Most of the comments of my earlier post still
apply, with some additions (noted *)

(i) fits a single classification tree to dataset (R function CT)
   (ii) basic functionality of Random Forest, e.g. bagged trees with choices
about sample size, with/without replacement, size of (random) subset
of covariates drawn when nodes are split.  Result contains the oob 
votes,
and a matrix representing the forest structure.
 *(iii) for each element of the sample, discovers all unique paths from a root 
node to 
a terminal node as a sequence of splits on covariates and uses these to 
fit
a lasso regresssion to the binary response using a full 
c-implementation of
the Turlach lasso2 function gl1ce.

It is now available at http://mysite.verizon.net/izmirlian/woods_1.00.tar.gz


Grant Izmirlian
NCI

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


Re: [Rd] Classification Trees and basic Random Forest pkg using tree structures in C

2005-11-04 Thread Izmirlian, Grant \(NIH/NCI\)
Hello Hin-Tak:

Thanks for your interest. This is just a short not to tell you and others that
the URL idea is a good one. This will take a few days at our organization.
When its available I will post again to this thread. In the meantime, I will
will send copies directly to those interested. So far, you and one other person.

Regards,

Grant

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


[Rd] Classification Trees and basic Random Forest pkg using tree structures in C

2005-11-04 Thread Izmirlian, Grant \(NIH/NCI\)
Hello R-devel:

I have written a package, called "woods", that does classification trees
(R function CT), and currently, only the most basic functionality of
Random Forest, e.g. bagged trees with choices about sample size, with/without
replacement, size of (random) subset of covariates drawn when nodes are 
split.  My reason for writing this is twofold.  First, I wanted to base
this development entirely in C (as others have done), but using data structures 
such as a node, pointer to node (for trees), and pointer to pointer of node 
(for forests) implemented in C. The algorithm which
does bagging isn't any faster (its 30% slower) than one by Leo Breiman/Adele 
Cutler/Andy Liaw/ Matt Weiner. The CT function runs about equally as fast
as Professor Brian Ripley's.

The only interesting feature is that the tree structure has been implemented in 
C. Its a neater way to carry stuff around and I am 
guessing would make future implementation easier. 

Because of its inherent redundancy from the users standpoint, it isn't
something to send to CRAN. However, I was wondering whether anyone is
interested in a copy?

Grant Izmirlian
NCI

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