[R] 'Math' group generic functions. Cant explain behaviour of 'log'.

Eryk Wolski wolski at molgen.mpg.de
Sun Jan 25 23:58:41 CET 2004


Hi!

Out of all 'Math' group generic functions(?Math) the log function has
a different behaviour. See example bellow.
Whats the reason?

Platfom Windows 2000.

R : Copyright 2003, The R Foundation for Statistical Computing
Version 1.8.1  (2003-11-21), ISBN 3-900051-00-3

>setClass("track",representation(x="numeric",y="numeric"))
>setMethod("Math","track",function(x)
+          {
+            x at y=callGeneric(x at y)
+            x
+          }
+          )
>xx<-new("track",x=1:10,y=-(1:10))
>xx<-abs(xx)
>sqrt(xx)
An object of class "track"
Slot "x":
 [1]  1  2  3  4  5  6  7  8  9 10

Slot "y":
 [1] 1.000000 1.414214 1.732051 2.000000 2.236068 2.449490 2.645751
2.828427
 [9] 3.000000 3.162278
>log(xx)
Error in log(x) : Non-numeric argument to mathematical function

Sincerely Eryk




More information about the R-help mailing list