Re: [R] Environmental oddity --- reproducible example.

2021-11-06 Thread Rolf Turner
library(Deriv) d1 <- Deriv(dnorm,"sd") source("d2.txt") # d2.txt is attached d1(1,0,3,TRUE) # [1] -0.2962963 d2(1,0,3,TRUE) # [1] -0.889 cheers, Rolf P.S.: > sessionInfo() R version 4.1.1 (2021-08-10) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.3 LTS Matrix product

Re: [R] Dispatching on 2 arguments?

2021-11-06 Thread Andrew Simmons
If you want to use the 'methods' package, you could do something like: replace <- function (p1, p2, ...) { stop(gettextf("cannot 'replace' with arguments of class %s and %s", sQuote(class(p1)[1L]), sQuote(class(p2)[1L]))) } methods::setGeneric("replace") methods::setMethod("replac

[R] Dispatching on 2 arguments?

2021-11-06 Thread Leonard Mada via R-help
Dear List-members, I would like to experiment with dispatching on 2 arguments and have a few questions. p1 = data.frame(x=1:3, coeff=1) class(p1) = c("pm", class(p1)); I want to replace variables in a polynomial with either: another polynomial, or another variable (character) or with a spec

Re: [R] Environmental oddity.

2021-11-06 Thread Deepayan Sarkar
On Sun, Nov 7, 2021 at 6:05 AM Rolf Turner wrote: > > > I have two functions which appear to differ only in their environments. > They look like: > > > d1 > > function (x, mean = 0, sd = 1, log = FALSE) > > (((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd)/sd > > > > and > > > d2 > > f

Re: [R] Environmental oddity.

2021-11-06 Thread Jeff Newmiller
In general, the search for symbols for a function Z in a package Y will span only those namespaces that the package Y specifies. The search for symbols in a function whose parent environment is the global environment will start there, thereby opening the door to find masking versions of function

[R] Environmental oddity.

2021-11-06 Thread Rolf Turner
I have two functions which appear to differ only in their environments. They look like: > d1 > function (x, mean = 0, sd = 1, log = FALSE) > (((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd)/sd > and > d2 > function (x, mean = 0, sd = 1, log = FALSE) > (((x - mean)/sd)^2 - 1) * i

Re: [R] extracting a R object from an R image

2021-11-06 Thread Martin Maechler
> Jeff Newmiller > on Fri, 05 Nov 2021 16:45:02 -0700 writes: > IMO you are being a bit too literal. It is absolutely possible to load the file into a dedicated environment and use the $ or [[]] extraction operator to access a specific object in that environment. > ?load

Re: [R] bootstrap confidence intervals

2021-11-06 Thread Rui Barradas
Hello, Às 01:36 de 06/11/21, David Winsemius escreveu: On 11/5/21 1:16 PM, varin sacha via R-help wrote: Dear R-experts, Here is a toy example. How can I get the bootstrap confidence intervals working ? Many thanks for your help library(DescTools) library(boo