Re: [Rd] S4 coercion responsibility

2008-09-17 Thread Seth Falcon
Continuing to talk to myself here... * On 2008-09-17 at 21:06 -0700 Seth Falcon wrote: > *argh* I'm certain this was working for me and yet when I try to > reproduce in a new R shell it errors out. This looks like an infelicity in the methods caching. To make it work: library("RSQLite")

Re: [Rd] S4 coercion responsibility

2008-09-17 Thread Seth Falcon
* On 2008-09-17 at 19:25 -0700 Seth Falcon wrote: > In the latest R-devel code (svn r46542), this behaves differently (and > works as you were hoping). I get: > > library("RSQLite") > setClass("SQLConPlus", contains=c("SQLiteConnection","integer")) > dd = data.frame(a=1:3, b=letters[1

Re: [Rd] S4 coercion responsibility

2008-09-17 Thread Seth Falcon
A couple more comments... * On 2008-09-15 at 10:07 -0700 Seth Falcon wrote: > > The example is with RSQLite but the same thing happens with > > RMySQL, and other DBI packages. The use of as() within the various DBI packages should be re-evaluated. I suspect some of that code was among the first

Re: [Rd] Dates in C api

2008-09-17 Thread Lee, Philip (IT)
Thanks, everyone, for the responses. That's exactly what I was after. Regards, Phil > -Original Message- > From: Jeff Ryan [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 17, 2008 4:19 PM > To: Lee, Philip (IT) > Cc: r-devel@r-project.org > Subject: Re: [Rd] Dates in C api > >

Re: [Rd] Dates in C api

2008-09-17 Thread Jeff Ryan
If you are looking for examples of handling dates/times (specifically POSIXct) within C code, the dev branch of xts has quite a bit of code now. http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/dev/pkg/src/?root=xts Assigning the class (or any attribute) within the C code will be much fast

Re: [Rd] Dates in C api

2008-09-17 Thread Duncan Murdoch
On 9/17/2008 1:24 PM, Lee, Philip (IT) wrote: r-devel, I've been trying to write a C plugin for R, and I'm struggling to understand how dates are represented. I can create a date in R: mydate<-as.Date(1, origin="1900-01-01") mydate [1] "1900-01-02" See ?Date for the internal represention: i

Re: [Rd] Dates in C api

2008-09-17 Thread Oleg Sklyar
Dates are number of days since 1970-01-01 that is it. to get data of Date in C: library(inline) code = 'Rprintf("%f", REAL(x)[0]); return R_NilValue;' f = cfunction(signature(x="double"), body=code) na = f(Sys.date()) to create an object of class Date: --- in C --- SEXP res = allocVector(REALSX

[Rd] Dates in C api

2008-09-17 Thread Lee, Philip (IT)
r-devel, I've been trying to write a C plugin for R, and I'm struggling to understand how dates are represented. I can create a date in R: > mydate<-as.Date(1, origin="1900-01-01") mydate [1] "1900-01-02" When I pass my date to a plugin, though, it's type is that of a real. There doesn't seem to