Re: [Rd] Incorrect formatted output after subtracting non-integer seconds from POSIXt origin

2010-09-03 Thread Daniel Murphy
Thanks. Yes, negative POSIX time would correspond to dates prior to 1970-1-1, or to dates prior to a more recent origin that borrows functionality from the POSIXt class: as.POSIXct(-.5, origin=as.POSIXct("2011-1-1")). > > If negative POSIX time is supposed to work then it's a bug in as.POSIXlt().

[Rd] Incorrect formatted output after subtracting non-integer seconds from POSIXt origin

2010-09-03 Thread Daniel Murphy
> x<-as.POSIXct("1970-1-1", tz="UTC")-.5 > y<-as.POSIXct("1970-1-1", tz="UTC")+.5 > x==y [1] FALSE # of course but x and y "appear" to be the same when formatted, even with extra precision: > format(x, format="%Y-%m-%d %H:%M:%OS2") [1] "1970-01-01 00:00:00.50" > format(y, format="%Y-%m-%d %H:%M:%O

Re: [Rd] Extract callNextMethod "array" calls "matrix"?

2010-07-21 Thread Daniel Murphy
e, > the bug won't likely be fixed soon, so any workaround that avoids the use of > callNextMethod on `[` with 3 or more subscripts is a good idea. > > > On 7/20/10 1:41 PM, Daniel Murphy wrote: > >> I have a class that extends array and my method for "[" stops wi

[Rd] Extract callNextMethod "array" calls "matrix"?

2010-07-20 Thread Daniel Murphy
I have a class that extends array and my method for "[" stops with an error: > setClass("A", contains="array") [1] "A" > setMethod("[", "A", function(x, i, j, ..., drop = TRUE) new("A", callNextMethod())) [1] "[" > a<-new("A",array(1:12,c(4,3,1))) > a An object of class "A" , , 1 [,1] [,2] [

Re: [Rd] S4 class extends "data.frame", getDataPart sees "list"

2010-07-13 Thread Daniel Murphy
OK, I see. Thanks. -Dan On Tue, Jul 13, 2010 at 9:11 AM, John Chambers wrote: > > On 7/13/10 8:43 AM, Daniel Murphy wrote: > >> Thank you. For "getDataPart" I was following (my interpretation of) >> advice from the documentation for "Classes": The fu

Re: [Rd] S4 class extends "data.frame", getDataPart sees "list"

2010-07-13 Thread Daniel Murphy
tDataPart> are a cleaner, but essentially equivalent way to deal with the data part. I interpreted "cleaner" to mean "preferred." From your reply, John, it sounds like I should go back to the obj...@.data construct. -Dan On Tue, Jul 13, 2010 at 5:57 AM, John Chambers wrote: >

[Rd] S4 class extends "data.frame", getDataPart sees "list"

2010-07-11 Thread Daniel Murphy
R-Devel: When I get the data part of an S4 class that contains="data.frame", it gives me a list, even when the "data.frame" is the S4 version: > d<-data.frame(x=1:3) > isS4(d) [1] FALSE # of course > dS4<-new("data.frame",d) > isS4(dS4) [1] TRUE

Re: [Rd] Attributes of 1st argument in ...

2010-07-05 Thread Daniel Murphy
s occurred based on the first argument, which is back to my original post. I'm guessing that's too difficult to implement. Again, thanks to everyone for your time in schooling me on the issues. :-) Dan On Mon, Jul 5, 2010 at 10:35 PM, Daniel Murphy wrote: > I truly am grateful for al

Re: [Rd] Attributes of 1st argument in ...

2010-07-05 Thread Daniel Murphy
cbind does not seem to know the symbol of unnamed arguments? E.g., x<-mpfr(0:7,100) cbind(x,x) If so, that seems a small price to pay for the S4 functionality. Thanks again. Cheers, Dan On Mon, Jul 5, 2010 at 2:47 AM, Martin Maechler wrote: > >>>>> "DM" == Daniel Mu

Re: [Rd] Attributes of 1st argument in ...

2010-07-04 Thread Daniel Murphy
Thank you, Professor, for drawing my attention to the nifty tracemem function. I'm using the ..1 syntax to check the properties of the S4 class at function call. The Description at ?"cBind" tells me that I'm not alone in this predicament. Just as Matrix needs its own cBind function, my package wil

Re: [Rd] Attributes of 1st argument in ...

2010-07-03 Thread Daniel Murphy
n Sat, Jul 3, 2010 at 9:17 AM, Hadley Wickham wrote: > Hi Dan, > > Is there a reason you can't change the function to > > f <- function(x, ...) {} > > ? > > Hadley > > On Fri, Jul 2, 2010 at 4:26 PM, Daniel Murphy > wrote: > > R-Devel: > > &

[Rd] Attributes of 1st argument in ...

2010-07-02 Thread Daniel Murphy
R-Devel: I am trying to get an attribute of the first argument in a call to a function whose formal arguments consist of dots only and do something, e.g., call 'cbind', based on the attribute f<- function(...) {get first attribute; maybe or maybe not call 'cbind'} I thought of (ignoring "deparse.

Re: [Rd] format: different S4 behavior in a package

2010-06-23 Thread Daniel Murphy
Thank you, Martin. That worked. And fyi 'export(format)' alone was not sufficient. Best, Dan On Wed, Jun 23, 2010 at 5:15 AM, Martin Morgan wrote: > On 06/23/2010 12:16 AM, Daniel Murphy wrote: > > R-Devel-ers: > > > > I have an S4 method that simply format

[Rd] format: different S4 behavior in a package

2010-06-23 Thread Daniel Murphy
R-Devel-ers: I have an S4 method that simply formats an object: setGeneric("formatMe", function(x) standardGeneric("formatMe")) setMethod("formatMe", "ANY", function(x) format(x)) If I issue the above in an R session, then define an S4 class with its own format method, I get the desired result:

Re: [Rd] Extract/format/show for S4 objects (Johann Hibschman)

2010-06-09 Thread Daniel Murphy
Johann, Following up on Gabor's reply, the mondate package (new on CRAN last week) will accomplish your needs. >I'm trying to make an integer-backed quarter (as in fraction of year) >class, but I can't quite it to work. I want integer-backed so I don't >have to worry about floating-point effects

Re: [Rd] pretty.Date(): new "halfmonth" time step

2010-05-20 Thread Daniel Murphy
has a frac= argument, > e.g. > > > library(zoo) > > ym <- as.yearmon("2010-01") > > as.Date(ym, frac = 0.5) > [1] "2010-01-16" > > > On Wed, May 19, 2010 at 9:56 PM, Daniel Murphy > wrote: > >>Much better to implement directly

Re: [Rd] pretty.Date(): new "halfmonth" time step

2010-05-20 Thread Daniel Murphy
lue for a halfway point complicates actuarial calculations. It could serve other purposes just fine, however. Best regards, Dan On Wed, May 19, 2010 at 7:48 PM, Felix Andrews wrote: > On 20 May 2010 11:56, Daniel Murphy wrote: > >>Much better to implement directly what this is trying

[Rd] pretty.Date(): new "halfmonth" time step

2010-05-19 Thread Daniel Murphy
>Much better to implement directly what this is trying to do: i.e. to >have a "halfmonth" time step. This is just the union of two "monthly" >sequences, one on the 1st of each month and another on the 15th of >each month. For some applications that might be true. But not for others. For a month wi

[Rd] format.data.frame containing S4 class with format method

2010-05-16 Thread Daniel Murphy
Hi again, I must be misunderstanding something fundamental about how an S4 class stored in a data.frame can be persuaded to print according to a desired format. The help page says: format.data.frame formats the data frame column by column, applying the appropriate method of format for each column

Re: [Rd] Validity glitch when contains="matrix"

2010-05-06 Thread Daniel Murphy
uot; fails to call validObject(). Should be > easy to fix. (Although it points out that the code should perhaps be > reorganized so the initialize() method is not responsible for checking > validity.) > > > Re: your other question: > > > On 5/6/10 4:09 AM, Martin Maechl

[Rd] Validity glitch when contains="matrix"

2010-05-05 Thread Daniel Murphy
Sirs: My validity function did not run when my class contains="matrix". But if I first define the class with contains="numeric", then define it again with contains="matrix", validity runs. Here's the session: > f <- function(object) "BAD CLASS" # force error to > setClass("A", contains="matrix",

[Rd] S4 method execution time

2010-04-30 Thread Daniel Murphy
Hello: I have written some an elementary S4 classes around a matrix to strengthen control of some key attributes. When I run a fairly elementary function ("f") on the matrix outside the class it runs instantaneously (elapsed system.time = 0) but when I setMethod "f" on myClass -- returning an inst

[Rd] choose.files() latent highlighting in console

2009-12-09 Thread Daniel Murphy
Greetings, When I call choose.files() from within a Windows (Vista or XP) Rgui.exe (2.10.0) session and double-click my choice, a large section of the text in the 'R Console' window appears as "selected" (highlighted in blue) when control returns to the console. The end point of the selected text

Re: [Rd] Help in 2.10 lost its "Find" feature

2009-11-11 Thread Daniel Murphy
That did it. Was having trouble searching 'help' for how to optionally configure 'help'. Thanks. -Dan On Wed, Nov 11, 2009 at 8:57 AM, Henrik Bengtsson wrote: > For the text based help, there is no search feature on Windows, e.g. > > options(help_type="text"); > help(readLines); > > but if you us

[Rd] Help in 2.10 lost its "Find" feature

2009-11-11 Thread Daniel Murphy
Sirs: I understand that no one wanted to maintain the old Help, but one feature I used extensively -- as a newbie to R or to an unfamiliar package -- was the capability of searching for a word or phrase on the Help page itself. Ctrl-F/Command-F (Windows/mac) 'differently-phrased-capability' was a

Re: [Rd] Match .3 in a sequence

2009-03-17 Thread Daniel Murphy
only exact 0 will match 0 > > Hope this helps, > > -s > > On Mon, Mar 16, 2009 at 9:36 AM, Daniel Murphy > wrote: > > Hello:I am trying to match the value 0.3 in the sequence seq(.2,.3). I > get > >> 0.3 %in% seq(from=.2,to=.3) > > [1] FALSE &

Re: [Rd] Match .3 in a sequence

2009-03-16 Thread Daniel Murphy
< nums[3] < nums[4], fact[1] compares > *unequal* to fact[2] though it compares *equal* to fact[4]. > Apparently R is comparing the *names* of the levels rather than the > indexes in the factor. This would be weird even if it didn't lead to > this very bad case. > > Hop

Re: [Rd] Match .3 in a sequence

2009-03-16 Thread Daniel Murphy
t; approxin <- function(x,list,tol) any(abs(list-x) tolerance > > rapproxin <- function(x,list,tol) (x==0 && 0 %in% list) || > any(abs((list-x)/x)<=tol,na.rm=TRUE) > # relative tolerance; only exact 0 will match 0 > > Hope this helps, > > -s > &

[Rd] Match .3 in a sequence

2009-03-16 Thread Daniel Murphy
Hello:I am trying to match the value 0.3 in the sequence seq(.2,.3). I get > 0.3 %in% seq(from=.2,to=.3) [1] FALSE Yet > 0.3 %in% c(.2,.3) [1] TRUE For arbitrary sequences, this "invisible .3" has been problematic. What is the best way to work around this? Thank you. Dan [[alternative HTML