[R] Create Model Object (setClass?setMethod?)
R. Michael Weylandt
michael.weylandt at gmail.com
Tue Apr 3 21:22:36 CEST 2012
Setting a class is quite easy if you are in the S3 (read: easier) system:
x <- 1:15
class(x) <- "YourClass"
summary.YourClass <- function(x, ...) cat("The mean of your object is
", mean(x), "\n")
summary(x)
Michael
On Tue, Apr 3, 2012 at 12:54 PM, casperyc <casperyc at hotmail.co.uk> wrote:
> Hi all,
>
> I have a self written likelihood as a model and functions to optimize and
> get fitted values, confidence intervals ect.
>
> I wonder if there is a way to define a 'class', or a 'model' (or a certain
> object)? so that I can use 'summary' to produce a summary like it does for a
> lm object.
>
> Also, it should be able to use 'predict' and 'plot' and other various
> generic functions.
>
> I am reading bits and pieces on the internet on 'setClass', 'setMethod'. Am
> I looking for the correct thing? Is there any up to date references that I
> can get help? I need some examples to get started with.
>
> Thanks!
>
> Casper
>
> -----
> ###################################################
> PhD candidate in Statistics
> School of Mathematics, Statistics and Actuarial Science, University of Kent
> ###################################################
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Create-Model-Object-setClass-setMethod-tp4529473p4529473.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list