[Rd] dhyper, phyper (PR#10853)
Aloha all, I know too little about what I'm about to write and hope I'm not wasting your time. For a class I'm teaching in archaeological data analysis, I'm trying to put together a routine that calculates the so-called Petersen index and, especially, confidence intervals for the index. This was introduced to archaeologists by N.R.J. Fieller and A. Turner in an article in Journal of Archaeological Science (1982) called Number Estimation in Vertebrate Samples. They say that "calculation of precise confidence intervals for population sizes is, in principle at least, straightforward. It involves calculation of cumulative hypergeometric probabilities (i.e. the summation of probabilities given by equation 3.1 of Seber, 1973)." The reference is to G.A.F. Seber's book, The Estimation of Animal Abundance. I went to equation 3.1 and wrote a small function to sum its probabilities, modeled after phyper() and taking the arguments in the same order (the names have changed to suit the archaeological situation): > seber <- function(p,l,n,r) > { > y <- 0 > for (x in 0:p) > y <- y + exp(lchoose(l,x) + lchoose(n-l,r-x) - lchoose(n,r)) > y > } When used in the larger routine, this yields results that very closely approximate the results in Fieller and Turner's table 1. I initially thought I could use the function phyper() for this because, as I interpret the help files, this routine yields cumulative hypergeometric probabilities. But I'm finding that it gives different results than seber(). I apologize if I am in too far over my head, but I am wondering if this is a bug in dhyper/phyper? Perhaps I have misunderstood what phyper() actually does, or am calling it incorrectly? Or, were Fieller and Turner in error? All the best, Tom Thomas Dye Dean Hall 201, Tuesday 1:00-1:55 pm __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] MacOSX R.app do not save history (PR#10850)
Full_Name: Anuar Konkashbaev Version: 2.6.2 OS: Mac OS X 10.4.11 Submission from: (NULL) (128.135.32.210) R.app do not saves history while command line r does. When starting R.app history from the command line session and all new commands from current session are available, but when quiting R.app .Rhistory is overwritten but only commands from command line session are saved in new file. Even if one will save history explicitly with savehistory(".Rhistory") only commands from command line session are saved in the .Rhistory file. .Rdata is saved correctly. History works just fine in command line application. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Warnings generated by log2()/log10() are really large/takes a long time to display
Thank you Henrik, > "HenrikB" == Henrik Bengtsson <[EMAIL PROTECTED]> > on Tue, 26 Feb 2008 22:03:24 -0800 writes: {with many superfluous empty statements ( i.e., trailing ";" ): HenrikB> x <- rnorm(1e6); [] HenrikB> y <- log2(x); # or log10(x) HenrikB> w <- warnings(); HenrikB> print(object.size(w)); HenrikB> ## [1] 8000536 HenrikB> str(w); HenrikB> ## List of 1 HenrikB> ## $ NaNs produced: language log(c(2.12082478659910, HenrikB> 1.40263187453398, 1.574125429 HenrikB> ## 83486, -0.816399069824751, 0.215940065840533, 1.20975177084379, HenrikB> -0.340287874362 HenrikB> ## 813, 0.117151537611550, ... HenrikB> ## - attr(*, "dots")= list() HenrikB> ## - attr(*, "class")= chr "warnings" HenrikB> Note also how long it takes to display and str() the warning. Yes, indeed. It's a subtle problem and happens because in do_log1arg() a new call is constructed in which 'x' has already been evaluated. A subtle fix to the subtle problem is to replace CAR(args) by CADR(call) in there --- arithmetic.c(Revision 44626) +++ arithmetic.c(working copy) @@ -1372,7 +1372,9 @@ if(PRIMVAL(op) == 10) tmp = ScalarReal(10.0); if(PRIMVAL(op) == 2) tmp = ScalarReal(2.0); -PROTECT(Call = lang3(install("log"), CAR(args), tmp)); +/* CADR(call) instead of CAR(args), since 'args' have been + * evaluated in Dispatch*(..) above : */ +PROTECT(Call = lang3(install("log"), CADR(call), tmp)); res = eval(Call, env); UNPROTECT(1); return res; - That does fix the problem you've reported (and passes "make check") but I'm not quite at ease with it, since it will lead to effectively evaluate the argument *twice*. A different approach that I'd find cleaner would be to *not* construct and eval() a new Call inside do_log1arg, but I assume there had been a good reason for doing things they way they are now... Martin Maechler, ETH Zurich __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Warnings generated by log2()/log10() are really large/takes a long time to display
On Wed, 27 Feb 2008, Martin Maechler wrote: > Thank you Henrik, > >> "HenrikB" == Henrik Bengtsson <[EMAIL PROTECTED]> >> on Tue, 26 Feb 2008 22:03:24 -0800 writes: > > {with many superfluous empty statements ( i.e., trailing ";" ): Indeed! >HenrikB> x <- rnorm(1e6); > >[] > > >HenrikB> y <- log2(x); # or log10(x) >HenrikB> w <- warnings(); >HenrikB> print(object.size(w)); >HenrikB> ## [1] 8000536 >HenrikB> str(w); >HenrikB> ## List of 1 >HenrikB> ## $ NaNs produced: language log(c(2.12082478659910, >HenrikB> 1.40263187453398, 1.574125429 >HenrikB> ## 83486, -0.816399069824751, 0.215940065840533, > 1.20975177084379, >HenrikB> -0.340287874362 >HenrikB> ## 813, 0.117151537611550, ... >HenrikB> ## - attr(*, "dots")= list() >HenrikB> ## - attr(*, "class")= chr "warnings" > >HenrikB> Note also how long it takes to display and str() the warning. > > Yes, indeed. > It's a subtle problem and happens > because in do_log1arg() a new call is constructed in which 'x' > has already been evaluated. > > A subtle fix to the subtle problem > is to replace CAR(args) by CADR(call) in there > > --- arithmetic.c (Revision 44626) > +++ arithmetic.c (working copy) > @@ -1372,7 +1372,9 @@ > if(PRIMVAL(op) == 10) tmp = ScalarReal(10.0); > if(PRIMVAL(op) == 2) tmp = ScalarReal(2.0); > > -PROTECT(Call = lang3(install("log"), CAR(args), tmp)); > +/* CADR(call) instead of CAR(args), since 'args' have been > + * evaluated in Dispatch*(..) above : */ > +PROTECT(Call = lang3(install("log"), CADR(call), tmp)); > res = eval(Call, env); > UNPROTECT(1); > return res; > > - > > That does fix the problem you've reported (and passes "make check") > but I'm not quite at ease with it, since it will lead to > effectively evaluate the argument *twice*. > > A different approach that I'd find cleaner > would be to *not* construct and eval() a > new Call inside do_log1arg, but I assume there had been a good > reason for doing things they way they are now... There was (although possibly no longer -- there was a bug in S4 dispatch of primitives that failed to re-promise args). The real issue is somewhere else entirely, the complete deparse in print.warnings. > > Martin Maechler, ETH Zurich > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Warnings generated by log2()/log10() are really large/takes a long time to display
On Wed, Feb 27, 2008 at 12:56 AM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > On Wed, 27 Feb 2008, Martin Maechler wrote: > > > Thank you Henrik, > > > >> "HenrikB" == Henrik Bengtsson <[EMAIL PROTECTED]> > >> on Tue, 26 Feb 2008 22:03:24 -0800 writes: > > > > {with many superfluous empty statements ( i.e., trailing ";" ): > > Indeed! I like to add a personal touch to the code I'm writing ;) Seriously, I added them here as a bait in order to get a chance to say that I finally found a good reason for adding the semicolons. If you cut'n'paste code from certain web pages it may happen that newlines/carriage returns are not transferred and all code is pasted into the same line at the R prompt. With semicolons you still get a valid syntax. I cannot remember under what conditions this happened - if it was for certain web browser, web page/blog, online page editor, OS and so, but I'm quite sure it was while I've put online code examples for my latest project. Maybe someoneelse also has noticed this? > > > > >HenrikB> x <- rnorm(1e6); > > > >[] > > > > > >HenrikB> y <- log2(x); # or log10(x) > >HenrikB> w <- warnings(); > >HenrikB> print(object.size(w)); > >HenrikB> ## [1] 8000536 > >HenrikB> str(w); > >HenrikB> ## List of 1 > >HenrikB> ## $ NaNs produced: language log(c(2.12082478659910, > >HenrikB> 1.40263187453398, 1.574125429 > >HenrikB> ## 83486, -0.816399069824751, 0.215940065840533, > 1.20975177084379, > >HenrikB> -0.340287874362 > >HenrikB> ## 813, 0.117151537611550, ... > >HenrikB> ## - attr(*, "dots")= list() > >HenrikB> ## - attr(*, "class")= chr "warnings" > > > >HenrikB> Note also how long it takes to display and str() the warning. > > > > Yes, indeed. > > It's a subtle problem and happens > > because in do_log1arg() a new call is constructed in which 'x' > > has already been evaluated. > > > > A subtle fix to the subtle problem > > is to replace CAR(args) by CADR(call) in there > > > > --- arithmetic.c (Revision 44626) > > +++ arithmetic.c (working copy) > > @@ -1372,7 +1372,9 @@ > > if(PRIMVAL(op) == 10) tmp = ScalarReal(10.0); > > if(PRIMVAL(op) == 2) tmp = ScalarReal(2.0); > > > > -PROTECT(Call = lang3(install("log"), CAR(args), tmp)); > > +/* CADR(call) instead of CAR(args), since 'args' have been > > + * evaluated in Dispatch*(..) above : */ > > +PROTECT(Call = lang3(install("log"), CADR(call), tmp)); > > res = eval(Call, env); > > UNPROTECT(1); > > return res; > > > > - > > > > That does fix the problem you've reported (and passes "make check") > > but I'm not quite at ease with it, since it will lead to > > effectively evaluate the argument *twice*. > > > > A different approach that I'd find cleaner > > would be to *not* construct and eval() a > > new Call inside do_log1arg, but I assume there had been a good > > reason for doing things they way they are now... > > There was (although possibly no longer -- there was a bug in S4 dispatch > of primitives that failed to re-promise args). > > The real issue is somewhere else entirely, the complete deparse in > print.warnings. Thank you both for looking into this. Henrik > > > > > Martin Maechler, ETH Zurich > > > > __ > > R-devel@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > -- > Brian D. Ripley, [EMAIL PROTECTED] > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UKFax: +44 1865 272595 > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Generic Functions
Thanks a lot for your explanation, which I higly appreciate. But I have still a problem... Think about 2 persons, each of them create their own package. Both define a generic function "setType" with different arguments. Person 1: setType(obj, valX) Person 2: setType(spec) If I require the package of person 1, everything works fine. If I call the second package afterwards, I will get an error, because the generic function already exists. How can I solve this conflict? How can I define a new generic function which has different arguments without getting in trouble with the first package? Is there a way to define functions, which belongs to a specific class without getting in troubles with other packages? Thanks a lot for your help. Dominik -Ursprüngliche Nachricht- Von: Martin Morgan [mailto:[EMAIL PROTECTED] Gesendet: Montag, 25. Februar 2008 19:54 An: Dominik Locher Betreff: Re: AW: [R] Generic Functions Things are different in R. You can't protect a new function from hiding your function, just as > print(1:10) [1] 1 2 3 4 5 6 7 8 9 10 > print <- function(x) "oops" > print(1:10) [1] "oops" > rm(print) > print(1:10) [1] 1 2 3 4 5 6 7 8 9 10 Note that the redefinition hides but does not remove 'print' function. Generics don't really belong with classes, but if you think about it something like class Foo { function bar() {} } foo = new Foo; $foo->bar() in php is very similar to > setClass("Foo", "list") > setGeneric("bar", function(x) standardGeneric("bar")) setMethod("bar", > "Foo", function(x) {}) foo = new("Foo") > bar(foo) i.e., set a method on the generic function. Someone could write another method 'bar' operating on a different object, and it would coexist with your method. Martin "Dominik Locher" <[EMAIL PROTECTED]> writes: > Hi > > Many thanks for your explanation. Just another short question. How can > I make sure that if I greate a new class with functions, that nobody > can change this functions anymore or as you mentioned overwrite > unintended this function (setType). > > In OOP i.e. in php I have a class and specific functions belongs to > this class. How can I do the same in R with generic functions? or is > there another way? > > Thanks for your help. > > Dominik > > > PS: I will send questions about S4 to R-devel@r-project.org in future. ;-). > > -Ursprüngliche Nachricht- > Von: Martin Morgan [mailto:[EMAIL PROTECTED] > Gesendet: Sonntag, 24. Februar 2008 17:59 > An: Dominik Locher > Cc: [EMAIL PROTECTED] > Betreff: Re: [R] Generic Functions > > See the 'useAsDefault' argument to setGeneric. > > As an aside, if 'setType<-' is meant to be a 'setter' to change the > value of a slot 'type', then I find the syntax a little redundant -- > it's use > > > setType(x) <- "foo" > > implies that it is already a 'setter' without 'set' at the front. Why > not just > > > type(x) <- "foo" > > (though perhaps 'type' is not such a good name, either)? > > As a second aside, if you're writing code that you expect to be used > with fPortfolio, then having two functions with the same name but > different signatures or overall goals will confuse your user -- with > fPortfolio, > setType<- works fine, but then for mysterious reasons (i.e., when your > package is loaded, with a different definition of setType<-) code that > worked before no longer works! So I'd either use setType in a way > consistent with it's use in fPortfolio, or define a new generic for > your own purposes > (setType<- is not a generic in my version of fPortfolio, > > > packageDescription('fPortfolio')$Version > [1] "260.72" > > ). > > As a third aside, I think questions about S4 probably belong on > R-devel, as they seem to fall in the realm of 'questions likely to > prompt discussion unintelligible to non-programmers' (from the R-devel > mailing list description). > > Martin > > Dominik Locher wrote: >> Hi >> >> I have some problems in defining new generic functions and classes. >> Just have a look at the following example: >> >> >> require(fPortfolio) >> >> setClass("PROBECLASS", >> representation( >> type="character" >> ) >> ) >> >> isGeneric("setType<-") >> #Returns >> TRUE >> >> #I would like to define a specific function for class PROBECLASS with >> other arguments than for the generic function "setType" of fPortfolio. >> setGeneric("setType<-", function(object, value) >> standardGeneric("setType<-")) >> >> #Returns >> Fehler in makeGeneric(name, fdef, fdeflt, group = group, valueClass = >> valueClass, : >> the formal arguments of the generic function for "setType<-" >> (object, >> value) differ from those of the non-generic to be used as the default >> (spec, >> value) >> >> setReplaceMethod("setType", "PROBECLASS", function(object, value){ >> >> [EMAIL PROTECTED] <- value >> object >> >> }) >> >> #Example
Re: [Rd] dhyper, phyper (PR#10853)
[EMAIL PROTECTED] wrote: > Aloha all, > > I know too little about what I'm about to write and hope I'm not > wasting your time. > > For a class I'm teaching in archaeological data analysis, I'm trying > to put together a routine that calculates the so-called Petersen > index and, especially, confidence intervals for the index. This was > introduced to archaeologists by N.R.J. Fieller and A. Turner in an > article in Journal of Archaeological Science (1982) called Number > Estimation in Vertebrate Samples. They say that "calculation of > precise confidence intervals for population sizes is, in principle at > least, straightforward. It involves calculation of cumulative > hypergeometric probabilities (i.e. the summation of probabilities > given by equation 3.1 of Seber, 1973)." The reference is to G.A.F. > Seber's book, The Estimation of Animal Abundance. > > I went to equation 3.1 and wrote a small function to sum its > probabilities, modeled after phyper() and taking the arguments in the > same order (the names have changed to suit the archaeological > situation): > > >> seber <- function(p,l,n,r) >> { >> y <- 0 >> for (x in 0:p) >> y <- y + exp(lchoose(l,x) + lchoose(n-l,r-x) - lchoose(n,r)) >> y >> } >> > > When used in the larger routine, this yields results that very > closely approximate the results in Fieller and Turner's table 1. > > I initially thought I could use the function phyper() for this > because, as I interpret the help files, this routine yields > cumulative hypergeometric probabilities. But I'm finding that it > gives different results than seber(). > Could you give an example? > I apologize if I am in too far over my head, but I am wondering if > this is a bug in dhyper/phyper? Perhaps I have misunderstood what > phyper() actually does, or am calling it incorrectly? Or, were > Fieller and Turner in error? I'd guess it's your error, but without seeing what you did can't really say for sure. By the way, please don't post things like this to the R-bugs list unless you're reasonably sure it's a bug. Entries on that list take work by busy people to clear up. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Generic Functions
Dominik Locher wrote: > Thanks a lot for your explanation, which I higly appreciate. But I have > still a problem... > > Think about 2 persons, each of them create their own package. Both define a > generic function "setType" with different arguments. > > Person 1: setType(obj, valX) > Person 2: setType(spec) > > If I require the package of person 1, everything works fine. > > If I call the second package afterwards, I will get an error, because the > generic function already exists. > > How can I solve this conflict? How can I define a new generic function which > has different arguments without getting in trouble with the first package? > Is there a way to define functions, which belongs to a specific class > without getting in troubles with other packages? > Use a NAMESPACE. Duncan Murdoch > Thanks a lot for your help. > Dominik > > > -Ursprüngliche Nachricht- > Von: Martin Morgan [mailto:[EMAIL PROTECTED] > Gesendet: Montag, 25. Februar 2008 19:54 > An: Dominik Locher > Betreff: Re: AW: [R] Generic Functions > > Things are different in R. You can't protect a new function from hiding your > function, just as > > >> print(1:10) >> > [1] 1 2 3 4 5 6 7 8 9 10 > >> print <- function(x) "oops" >> print(1:10) >> > [1] "oops" > >> rm(print) >> print(1:10) >> > [1] 1 2 3 4 5 6 7 8 9 10 > > Note that the redefinition hides but does not remove 'print' function. > > Generics don't really belong with classes, but if you think about it > something like > > class Foo { > function bar() {} > } > > foo = new Foo; > $foo->bar() > > in php is very similar to > > >> setClass("Foo", "list") >> setGeneric("bar", function(x) standardGeneric("bar")) setMethod("bar", >> "Foo", function(x) {}) foo = new("Foo") >> bar(foo) >> > > i.e., set a method on the generic function. Someone could write another > method 'bar' operating on a different object, and it would coexist with your > method. > > Martin > > "Dominik Locher" <[EMAIL PROTECTED]> writes: > > >> Hi >> >> Many thanks for your explanation. Just another short question. How can >> I make sure that if I greate a new class with functions, that nobody >> can change this functions anymore or as you mentioned overwrite >> unintended this function (setType). >> >> In OOP i.e. in php I have a class and specific functions belongs to >> this class. How can I do the same in R with generic functions? or is >> there another way? >> >> Thanks for your help. >> >> Dominik >> >> >> PS: I will send questions about S4 to R-devel@r-project.org in future. >> > ;-). > >> -Ursprüngliche Nachricht- >> Von: Martin Morgan [mailto:[EMAIL PROTECTED] >> Gesendet: Sonntag, 24. Februar 2008 17:59 >> An: Dominik Locher >> Cc: [EMAIL PROTECTED] >> Betreff: Re: [R] Generic Functions >> >> See the 'useAsDefault' argument to setGeneric. >> >> As an aside, if 'setType<-' is meant to be a 'setter' to change the >> value of a slot 'type', then I find the syntax a little redundant -- >> it's use >> >> > setType(x) <- "foo" >> >> implies that it is already a 'setter' without 'set' at the front. Why >> not just >> >> > type(x) <- "foo" >> >> (though perhaps 'type' is not such a good name, either)? >> >> As a second aside, if you're writing code that you expect to be used >> with fPortfolio, then having two functions with the same name but >> different signatures or overall goals will confuse your user -- with >> fPortfolio, >> setType<- works fine, but then for mysterious reasons (i.e., when your >> package is loaded, with a different definition of setType<-) code that >> worked before no longer works! So I'd either use setType in a way >> consistent with it's use in fPortfolio, or define a new generic for >> your own purposes >> (setType<- is not a generic in my version of fPortfolio, >> >> > packageDescription('fPortfolio')$Version >> [1] "260.72" >> >> ). >> >> As a third aside, I think questions about S4 probably belong on >> R-devel, as they seem to fall in the realm of 'questions likely to >> prompt discussion unintelligible to non-programmers' (from the R-devel >> mailing list description). >> >> Martin >> >> Dominik Locher wrote: >> >>> Hi >>> >>> I have some problems in defining new generic functions and classes. >>> Just have a look at the following example: >>> >>> >>> require(fPortfolio) >>> >>> setClass("PROBECLASS", >>> representation( >>> type="character" >>> ) >>> ) >>> >>> isGeneric("setType<-") >>> #Returns >>> TRUE >>> >>> #I would like to define a specific function for class PROBECLASS with >>> other arguments than for the generic function "setType" of fPortfolio. >>> setGeneric("setType<-", function(object, value) >>> standardGeneric("setType<-")) >>> >>> #Returns >>> Fehler in makeGeneric(name, fdef, fdeflt, group = group, valueClass = >>> valueClass, : >>> the formal arguments of t
Re: [Rd] Warnings generated by log2()/log10() are really large/takes a long time to display
Yes Henrik, I've also noticed this when cutting and pasting code from here: http://ace.acadiau.ca/math/ACMMaC/Rmpi/sample.html Try the .Last function for example. Best wishes Richard. Henrik Bengtsson wrote: > On Wed, Feb 27, 2008 at 12:56 AM, Prof Brian Ripley > <[EMAIL PROTECTED]> wrote: > >> On Wed, 27 Feb 2008, Martin Maechler wrote: >> >> > Thank you Henrik, >> > >> >> "HenrikB" == Henrik Bengtsson <[EMAIL PROTECTED]> >> >> on Tue, 26 Feb 2008 22:03:24 -0800 writes: >> > >> > {with many superfluous empty statements ( i.e., trailing ";" ): >> >> Indeed! >> > > I like to add a personal touch to the code I'm writing ;) > > Seriously, I added them here as a bait in order to get a chance to say > that I finally found a good reason for adding the semicolons. If you > cut'n'paste code from certain web pages it may happen that > newlines/carriage returns are not transferred and all code is pasted > into the same line at the R prompt. With semicolons you still get a > valid syntax. I cannot remember under what conditions this happened - > if it was for certain web browser, web page/blog, online page editor, > OS and so, but I'm quite sure it was while I've put online code > examples for my latest project. Maybe someoneelse also has noticed > this? > > >> >> >HenrikB> x <- rnorm(1e6); >> > >> >[] >> > >> > >> >HenrikB> y <- log2(x); # or log10(x) >> >HenrikB> w <- warnings(); >> >HenrikB> print(object.size(w)); >> >HenrikB> ## [1] 8000536 >> >HenrikB> str(w); >> >HenrikB> ## List of 1 >> >HenrikB> ## $ NaNs produced: language log(c(2.12082478659910, >> >HenrikB> 1.40263187453398, 1.574125429 >> >HenrikB> ## 83486, -0.816399069824751, 0.215940065840533, >> 1.20975177084379, >> >HenrikB> -0.340287874362 >> >HenrikB> ## 813, 0.117151537611550, ... >> >HenrikB> ## - attr(*, "dots")= list() >> >HenrikB> ## - attr(*, "class")= chr "warnings" >> > >> >HenrikB> Note also how long it takes to display and str() the warning. >> > >> > Yes, indeed. >> > It's a subtle problem and happens >> > because in do_log1arg() a new call is constructed in which 'x' >> > has already been evaluated. >> > >> > A subtle fix to the subtle problem >> > is to replace CAR(args) by CADR(call) in there >> > >> > --- arithmetic.c (Revision 44626) >> > +++ arithmetic.c (working copy) >> > @@ -1372,7 +1372,9 @@ >> > if(PRIMVAL(op) == 10) tmp = ScalarReal(10.0); >> > if(PRIMVAL(op) == 2) tmp = ScalarReal(2.0); >> > >> > -PROTECT(Call = lang3(install("log"), CAR(args), tmp)); >> > +/* CADR(call) instead of CAR(args), since 'args' have been >> > + * evaluated in Dispatch*(..) above : */ >> > +PROTECT(Call = lang3(install("log"), CADR(call), tmp)); >> > res = eval(Call, env); >> > UNPROTECT(1); >> > return res; >> > >> > - >> > >> > That does fix the problem you've reported (and passes "make check") >> > but I'm not quite at ease with it, since it will lead to >> > effectively evaluate the argument *twice*. >> > >> > A different approach that I'd find cleaner >> > would be to *not* construct and eval() a >> > new Call inside do_log1arg, but I assume there had been a good >> > reason for doing things they way they are now... >> >> There was (although possibly no longer -- there was a bug in S4 dispatch >> of primitives that failed to re-promise args). >> >> The real issue is somewhere else entirely, the complete deparse in >> print.warnings. >> > > Thank you both for looking into this. > > Henrik > > >> > >> > Martin Maechler, ETH Zurich >> > >> > __ >> > R-devel@r-project.org mailing list >> > https://stat.ethz.ch/mailman/listinfo/r-devel >> > >> >> -- >> Brian D. Ripley, [EMAIL PROTECTED] >> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ >> University of Oxford, Tel: +44 1865 272861 (self) >> 1 South Parks Road, +44 1865 272866 (PA) >> Oxford OX1 3TG, UKFax: +44 1865 272595 >> >> > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Warnings generated by log2()/log10() are really large/takes a long time to display
On Wed, Feb 27, 2008 at 5:50 AM, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > On Wed, Feb 27, 2008 at 12:56 AM, Prof Brian Ripley > <[EMAIL PROTECTED]> wrote: > > On Wed, 27 Feb 2008, Martin Maechler wrote: > > > > > Thank you Henrik, > > > > > >> "HenrikB" == Henrik Bengtsson <[EMAIL PROTECTED]> > > >> on Tue, 26 Feb 2008 22:03:24 -0800 writes: > > > > > > {with many superfluous empty statements ( i.e., trailing ";" ): > > > > Indeed! > > I like to add a personal touch to the code I'm writing ;) > > Seriously, I added them here as a bait in order to get a chance to say > that I finally found a good reason for adding the semicolons. If you > cut'n'paste code from certain web pages it may happen that > newlines/carriage returns are not transferred and all code is pasted > into the same line at the R prompt. With semicolons you still get a > valid syntax. I cannot remember under what conditions this happened - I have seen that too and many others have as well since in some forums (not related to R) its common to indent all source lines by two spaces. Any line appearing without indentation must have been wrapped. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Warnings generated by log2()/log10() are really large/t
On 27-Feb-08 13:39:47, Gabor Grothendieck wrote: > On Wed, Feb 27, 2008 at 5:50 AM, Henrik Bengtsson > <[EMAIL PROTECTED]> wrote: >> On Wed, Feb 27, 2008 at 12:56 AM, Prof Brian Ripley >> <[EMAIL PROTECTED]> wrote: >> > On Wed, 27 Feb 2008, Martin Maechler wrote: >> > >> > > Thank you Henrik, >> > > >> > >> "HenrikB" == Henrik Bengtsson <[EMAIL PROTECTED]> >> > >> on Tue, 26 Feb 2008 22:03:24 -0800 writes: >> > > >> > > {with many superfluous empty statements ( i.e., trailing ";" ): >> > >> > Indeed! >> >> I like to add a personal touch to the code I'm writing ;) >> >> Seriously, I added them here as a bait in order to get a chance to say >> that I finally found a good reason for adding the semicolons. If you >> cut'n'paste code from certain web pages it may happen that >> newlines/carriage returns are not transferred and all code is pasted >> into the same line at the R prompt. With semicolons you still get a >> valid syntax. I cannot remember under what conditions this happened - > > I have seen that too and many others have as well since in some forums > (not related to R) its common to indent all source lines by two spaces. > Any line appearing without indentation must have been wrapped. A not-so-subtle solution to this (subtle or not) problem. NEVER paste from a browser (or a Word doc, or anything similar) into the R command interface. Paste only from pure plain text. Therefore, if you must paste, then paste first into a window where a pure-plain-text editor is running. Then you can see what you're getting, and can clean it up. After that, you can paste from this directly into R, or can save the file and source() it. Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 27-Feb-08 Time: 14:36:02 -- XFMail -- __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Unix-like touch to update modification timestamp of file?
"Henrik Bengtsson" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > is it possible to update the modification time stamp of a file using R > (on file systems supporting it)? For a Windows PC, if you have RTools in your path (from http://www.murdoch-sutherland.com/Rtools/installer.html), then you should be able to use the touch that's in the RTools\bin directory: system("touch sample.dat") efg Earl F. Glynn Bioinformatics Stowers Institute for Medical Research __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Unix-like touch to update modification timestamp of file?
If you only need Windows then this will do it even without RTools: shell("copy /b /v myfile +,,>nul") On Wed, Feb 27, 2008 at 11:12 AM, Earl F. Glynn <[EMAIL PROTECTED]> wrote: > "Henrik Bengtsson" <[EMAIL PROTECTED]> wrote in message > news:<[EMAIL PROTECTED]>... > > > > is it possible to update the modification time stamp of a file using R > > (on file systems supporting it)? > > For a Windows PC, if you have RTools in your path (from > http://www.murdoch-sutherland.com/Rtools/installer.html), then you should be > able to use the touch that's in the RTools\bin directory: > > system("touch sample.dat") > > efg > > Earl F. Glynn > Bioinformatics > Stowers Institute for Medical Research > > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Unix-like touch to update modification timestamp of file?
On Wed, Feb 27, 2008 at 8:24 AM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > If you only need Windows then this will do it even without RTools: > > shell("copy /b /v myfile +,,>nul") Interesting. Show I figured out that '+' is for "append", but how to interpret the two commas? Thanks to both you. Henrik > > > > > > On Wed, Feb 27, 2008 at 11:12 AM, Earl F. Glynn > <[EMAIL PROTECTED]> wrote: > > "Henrik Bengtsson" <[EMAIL PROTECTED]> wrote in message > > news:<[EMAIL PROTECTED]>... > > > > > > > is it possible to update the modification time stamp of a file using R > > > (on file systems supporting it)? > > > > For a Windows PC, if you have RTools in your path (from > > http://www.murdoch-sutherland.com/Rtools/installer.html), then you should > be > > able to use the touch that's in the RTools\bin directory: > > > > system("touch sample.dat") > > > > efg > > > > Earl F. Glynn > > Bioinformatics > > Stowers Institute for Medical Research > > > > > > __ > > R-devel@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Unix-like touch to update modification timestamp of file?
On Wed, Feb 27, 2008 at 1:27 PM, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > On Wed, Feb 27, 2008 at 8:24 AM, Gabor Grothendieck > <[EMAIL PROTECTED]> wrote: > > If you only need Windows then this will do it even without RTools: > > > > shell("copy /b /v myfile +,,>nul") > > Interesting. Show I figured out that '+' is for "append", but how to > interpret the two commas? > Commas generally have various undocumented effects in Windows batch and sometimes Microsoft mentions one: http://support.microsoft.com/kb/69581 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel