[Rd] request for patch in drop1 (add.R)

2011-02-23 Thread Ben Bolker
By changing three lines in drop1 from access based on $ to access based on standard accessor methods (terms() and residuals()), it becomes *much* easier to extend drop1 to work with other model types. The use of $ rather than accessors in this context seems to be an oversight rather than a

[Rd] factor() on a double vector

2011-02-23 Thread Hervé Pagès
Hi, When 'x' is a vector of doubles, it's not clear how 'factor(x)' compares its values in order to determine the levels. For example, here all the values in 'x' are conceptually the same: x - c(11/3, 2/3 + 4/3 + 5/3, 50 + 11/3 - 50, 7.1 - 103/30)

Re: [Rd] factor() on a double vector

2011-02-23 Thread Simon Urbanek
Herve, the answer is simple - it's as.character() - it has nothing to do with factor or table. as.character(x) [1] 3.67 3.67 3.66 3.67 That's what you are passing to factor, so you get the corresponding results. Cheers, Simon On Feb 23,

Re: [Rd] factor() on a double vector

2011-02-23 Thread Hervé Pagès
On 02/23/2011 12:09 PM, Simon Urbanek wrote: Herve, the answer is simple - it's as.character() - it has nothing to do with factor or table. as.character(x) [1] 3.67 3.67 3.66 3.67 That's what you are passing to factor, so you get the

Re: [Rd] request for patch in drop1 (add.R)

2011-02-23 Thread Martin Maechler
Ben Bolker bbol...@gmail.com on Wed, 23 Feb 2011 09:14:37 -0500 writes: By changing three lines in drop1 from access based on $ to access based on standard accessor methods (terms() and residuals()), it becomes *much* easier to extend drop1 to work with other model

Re: [Rd] request for patch in drop1 (add.R)

2011-02-23 Thread Ben Bolker
On 11-02-23 03:20 PM, Martin Maechler wrote: Ben Bolker bbol...@gmail.com on Wed, 23 Feb 2011 09:14:37 -0500 writes: By changing three lines in drop1 from access based on $ to access based on standard accessor methods (terms() and residuals()), it becomes *much* easier

Re: [Rd] request for patch in drop1 (add.R)

2011-02-23 Thread peter dalgaard
On Feb 23, 2011, at 21:38 , Ben Bolker wrote: Potentially, but I am personally much more interested in enabling drop1(), which seems to be a much more legitimate tool for testing terms in models than step(), which is so easy to abuse ... Yes, although repeated use of drop1() easily leads

[Rd] Easily switchable factor levels

2011-02-23 Thread Barry Rowlingson
I've recently been working with some California county-level data. The counties can be referred to as either FIPS codes, eg F060102, friendly names such as Del Norte County, names without 'County' on the end, names with 'CA' on the end (Del Norte County, CA). Different data sets use slightly

Re: [Rd] request for patch in drop1 (add.R)

2011-02-23 Thread Prof Brian Ripley
residuals() and $residuals are often very different: residuals() is generic, but even the default method is *not* simple extraction. Their values can be of different lengths: think about an lm fit with na.action = na.exclude. That is precisely the sort of thing the tests in add.R were

[Rd] system(wait = FALSE)

2011-02-23 Thread Oliver Soong
I'm having a very odd problem with system(wait = FALSE). I'm not entirely sure whether it's a bug in R or a problem on our end. It's related to a post a month or so ago in R-help which got no responses, but I have a little more to add. This command works as expected (I use c:\tmp since c:\

Re: [Rd] Easily switchable factor levels

2011-02-23 Thread Heinz Tuechler
To me this is a common situation, especially to switch between two languages. I solve it by separating the coding of values and their labels. Values are coded numerically or as character, and their labels are attached by a value.label attribute. When needed a modified factor function

Re: [Rd] request for patch in drop1 (add.R)

2011-02-23 Thread Ben Bolker
On 11-02-23 06:12 PM, Prof Brian Ripley wrote: residuals() and $residuals are often very different: residuals() is generic, but even the default method is *not* simple extraction. Their values can be of different lengths: think about an lm fit with na.action = na.exclude. That is precisely

[Rd] min/max of a vector with NAs and NaNs

2011-02-23 Thread Hervé Pagès
I get this (with R-2.12 and R-2.13, didn't try with earlier versions): max(c(NaN, NA)) [1] NA max(c(NA, NaN)) [1] NaN I get the same thing with min(). The fact that the result of 'max(x)' or 'min(x)' depends on the order of the elements in 'x' is surprising. It also seems to contradict the

Re: [Rd] system(wait = FALSE)

2011-02-23 Thread Prof Brian Ripley
On Wed, 23 Feb 2011, Oliver Soong wrote: I'm having a very odd problem with system(wait = FALSE). I'm not entirely sure whether it's a bug in R or a problem on our end. It's related to a post a month or so ago in R-help which got no responses, but I have a little more to add. Well, the