rClr icon indicating copy to clipboard operation
rClr copied to clipboard

Try to perform struct method but coreced to R-typed object

Open renkun-ken opened this issue 10 years ago • 2 comments

Some types of objects created by CLR are by default coerced to R-typed objects. For example,

library("rClr")
dt1 <- clrNew("System.DateTime", year = 2015L, month = 12L, day = 10L)

dt1 will be a POSIXct object in R. How can I call System.DateTime.AddDays method to the original object?

renkun-ken avatar Jan 29 '15 01:01 renkun-ken

+1, I'm having problems with this as well. In my case, I want to call DateTime().ToOADate() like so

clrCall(Sys.Date(), "ToOADate")

Kevin-Jin avatar Jul 29 '15 16:07 Kevin-Jin

DateTime objects are indeed converted to R constructs, on purpose. A possible workaround is to create a wrapper class around DateTime (or a set of static methods with DateTime parameters).

I take note of the need to have more convenient ways to have the option to convert .NET objects or not to R, but the use case is broader and need to be elicited further.

jmp75 avatar Jul 31 '15 01:07 jmp75