Wednesday, 18 September 2013

(trying to define a S3 function using UseMethod)

(trying to define a S3 function using UseMethod)

I am new to the programming R. I defined a function called liw.mstreeClass
and I defined as below, but when I run the program I am keep getting the
following errors:
# define method: lcosts(generic dispatch)
liw.mstreeClass <- function(nb, data, method, p) UseMethod("nbcosts"){
Error: unexpected '{' in "liw.mstreeClass <- function(nb, data, method, p)
UseMethod("nbcosts"){"
if(method=="penrose") { liw <-
mat2listw(penroseDis.mstreeClass((scale(data))))
return(liw)}
Error: object 'method' not found } Error: unexpected '}' in " }"
could someone help me? thanks :)

No comments:

Post a Comment