Re: [Rd] median methods
Brian. The example I have in mind is for functional data where there are several ways to define a median. For example, it can be defined as the pointwise median of a set of functions {f_j(x); j=1,...,n}. Or it can be defined as m(x) = arg min_{g(x)} \sum_j |g(x) - f_j(x)| dx. The latter can be calculated using several different algorithms, one of which is the Hossjer-Croux algorithm. So I want to write a function of the form median.fd <- function(x, method=c("hossjer-croux","pointwise")) where x is of class "fd" (functional data). Without a ... argument in the generic median function, I can't do this. There are no doubt other similar examples where an additional argument (or more) is required. Furthermore, this would make it consistent with mean() and quantile(). You can easily retain existing code by defining generic median as median(x,...). Then if an na.rm argument is passed without name, it will go through to median.default(x,na.rm) without a hitch. It should not affect existing methods since they must all have na.rm as a second argument also. So I am suggesting median(x, ...) which makes it more flexible for method writers, and I don't think it causes a problem for existing code. Best wishes, Rob On 27/04/2008, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > On Sat, 26 Apr 2008, Rob Hyndman wrote: > > > > Can we please have a ... argument in median() to make it possible to pass > > arguments to specific methods. > > > > Not without a reasoned case -- see 'Writing R Extensions' as to why it is a > non-trivial change that affects all existing methods (and there are some) -- > also S4 setMethod("median") calls (which there are too). > > There is also an argument as to where the ... should come -- probably > > function (x, ..., na.rm = FALSE) > > (but that could break some existing calls), and why should na.rm be on the > generic as well (it is not for mean nor quantile, for example)? > > So there have to be some pretty compelling arguments in favour. > > > -- > 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 > -- _ Rob J Hyndman Professor of Statistics, Monash University Editor-in-Chief, International Journal of Forecasting http://www.robhyndman.info/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] RFC: What should ?foo do?
Peter Dalgaard wrote: > Duncan Murdoch wrote: > >> I haven't done it, but I suspect we could introduce special behaviour >> for ??foo very easily. We could even have a whole hierarchy: >> >> ?foo, ??foo, ???foo, foo, ... >> >> >> > Heh, that's rather nice, actually. In words, that could read > > ?foo: tell me about foo! > ??foo: what can you tell me about foo? > ???foo: what can you tell me about things like foo? > foo: I don't know what I'm looking for but it might be something > related foo? > I quite like this. It seems very intuitive to me -- just match the number of question marks to the level of my frustration. Pat > You do have to be careful about messing with ?, though. I think many > people, including me, would pretty quickly go nuts if ?par suddenly > didn't work the way we're used to. > > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] S4 default for coercing
A couple of comments, 1. The problem is not actually in as() but in is(): > xx = Sys.time() > is(xx, "OptionalPOSIXct") [1] FALSE > class(xx) [1] "POSIXt" "POSIXct" This is in fact, an "unintended" change, aka bug. Will be fixed shortly. 2. However, as the last line of the above should remind us all, the POSIX*t objects are, at the least, an interesting but unintended use of S3 classes, since it's the second string in the class attribute that is effectively the identifying class of the object. Any treatment of the object in S4 will end up acting like class POSIXt. Expecting these objects to behave properly in S4 code is an act of faith not likely to be rewarded in general, even though Martin's specific example works once the bug in is() has been fixed. (My new book has an example of one workaround, namely to define two new S4 classes corresponding to POSIX[cl]t, which then extend the appropriate class plus POSIXt.) All that said (and your knuckles having been rapped by Martin) thanks for the bug report. John Martin Maechler wrote: > Yes, there's a change from R 2.6.2 to 2.7.0 that might have > been unintended and hence a bug. > The short version is this > > setClassUnion("OptionalPOSIXct", c("POSIXct", "NULL")) > > as(Sys.time(), "OptionalPOSIXct", strict=FALSE) > > which now gives >>> Error .. >>> no method or default for coercing "POSIXt" to "OptionalPOSIXct > > and used to work in 2.6.2. > Unfortunately, the expert master mind on these issues, > John Chambers, is basically offline these days, > and I'd rather have waited on his opinion on the issue. > Class unions are a bit special and from that may have been quite > untested. > > Excuse me, but why did you not find this when beta or even alpha > testing R 2.7.0? > We now have always 2 weeks of alpha testing and 1+1 week of beta > testing before an x.y.0 release, > *EXACTLY* in order to find such issues in time and > discuss about them {and John was around then ...} > > Best regards (all the same ;-), > Martin > > > > >> "PaulG" == Paul Gilbert <[EMAIL PROTECTED]> >> on Wed, 23 Apr 2008 11:01:21 -0400 writes: >> > > PaulG> Something has changed in the S4 default for coercing. Am I now > suppose > PaulG> to use setAs, or is there something else I should do to make this > work: > > PaulG> R version 2.7.0 (2008-04-22) > PaulG> > >> require("methods") > >> setClassUnion("OptionalPOSIXct", c("POSIXct", "NULL")) > PaulG> [1] "OptionalPOSIXct" > >> setClass("TSmetax", > PaulG> representation(serIDs="character", > ExtractionDate="OptionalPOSIXct" )) > PaulG> [1] "TSmetax" > >> setGeneric("TSmetax", def= function(x, ...) standardGeneric("TSmetax")) > PaulG> [1] "TSmetax" > >> setMethod("TSmetax", signature(x="character"), definition= > PaulG> function(x, ...){ > PaulG> new("TSmetax", serIDs=x, ExtractionDate=Sys.time()) } ) > PaulG> [1] "TSmetax" > > >> z <- new("TSmetax", serIDs="whatever", ExtractionDate= Sys.time()) > PaulG> Error in as(slotVal, slotClass, strict = FALSE) : > PaulG> no method or default for coercing "POSIXt" to "OptionalPOSIXct" > > PaulG> (It did work in R-2.6.2.) > > PaulG> Paul > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] View functionhas problems going beyond 65536 rows (PR#11291)
Full_Name: jim holtman Version: 2.7.0 OS: Winfows XP Submission from: (NULL) (75.186.87.163) I am using the "View" function to look at a data frame. If the data has more than 65535 rows in it, strange things happen. You can reproduce the problem with the following: x <- 1:66000 View(x) If you now take the scroll bar and move it to the end, you will see that the row number is now 464 and the bar has jumped back to that location. Now press the "End" and you will get to the end of the vector and the row number does show up as 66000. It appears there is some trucation happen when the value gets to be more than 65535 rows when using the scroll bar. You can move the scroll bar to about 65000 and the "Page Down" will move the data to the last row (66000). This problem only seems to happen when using the scroll bar to move within the data. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R_DEFAULT_DEVICE (PR#11294)
Setting enviroment variable R_DEFAULT_DEVICE causes an error. The patch below fixes this. I guess the same goes for R_INTERACTIVE_DEVICE. --- R-2.7.0/src/library/grDevices/R/zzz.R 2008-04-27 13:49:11.0 +0200 +++ R-2.7.0/src/library/grDevices/R/zzz.R.new 2008-04-27 13:59:37.0 +0200 @@ -22,7 +22,7 @@ extras <- if(.Platform$OS.type == "windows") list(windowsTimeouts = c(100L,500L)) else list(bitmapType = if(capabilities("aqua")) "quartz" else if(capabilities("cairo")) "cairo" else "Xlib") -defdev <- Sys.getenv("R_DEFAULT_DEVICE") +defdev <- as.character(Sys.getenv("R_DEFAULT_DEVICE")) if(!nzchar(defdev)) defdev <- "pdf" device <- if(interactive()) { intdev <- Sys.getenv("R_INTERACTIVE_DEVICE") --please do not edit the information below-- Version: platform = i686-pc-linux-gnu arch = i686 os = linux-gnu system = i686, linux-gnu status = major = 2 minor = 7.0 year = 2008 month = 04 day = 22 svn rev = 45424 language = R version.string = R version 2.7.0 (2008-04-22) Locale: [EMAIL PROTECTED];LC_NUMERIC=C;[EMAIL PROTECTED];LC_COLLATE=C;LC_MONETARY=C;[EMAIL PROTECTED];[EMAIL PROTECTED];LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;[EMAIL PROTECTED];LC_IDENTIFICATION=C Search Path: .GlobalEnv, package:stats, package:graphics, package:utils, package:datasets, package:grDevices, package:methods, Autoloads, package:base __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel