Re: [R] existing package (mmlcr) modification -- appropriate process?

From: Xiaohui Chen <chenxh007_at_gmail.com>
Date: Thu, 29 May 2008 18:43:21 -0700

Hi Jenny,

A simple solution is to add your line to the function, re-load/source the modified function to the console (e.g. by copy and paste). Then the new function with the same name as the original one will be called next time. If you don't want to use modified function any longer, just use rm(function_name).

X

Jennifer Thacher 写道:
> All:
>
> I am new to R and would like your help in identifying the appropriate
> process to follow in order to modify the output from an existing
> package. I've had difficulty finding an answer online, perhaps because
> I am using incorrect terminology.
>
> A package that I am using (mmlcr) invokes another package (multinom).
> An output of multinom is the standard errors, but this output is not
> provided within mmlcr. I would like to obtain the standard errors as
> an output of mmlcr.
>
> For your reference, this is relevant code that I identified in mmlcr,
> using getAnywhere{mmlcrfit.multinomlong}:
> function (object, weights, classnumber)
> {
> data <- object$data
> form.full <- formula(attr(data, "terms"))
> form <- object$shortform
> data$.wts <- weights[match(getGroups(data, form.full, 1),
> row.names(weights)), classnumber]
> component.multinom.result <- multinom(form, data = data,
> weights = .wts, na.action = na.exclude, subset = (.wts >
> 0), maxit = 150, trace = FALSE)
> object$coef[[classnumber]] <- pmin(pmax(coef(component.multinom.result),
> -30), 30)
> object
> }
>
> This code passes coefficient estimates from multinom to the mmlcr
> object. I would like for the program to also pass through the standard
> error estimates. If this was my own code, I could just add a line to
> the above function. But in this case, since it is someone's else's
> code, I'm unsure how to modify it. Do I need to create a package
> (e.g., follow the process outlined in Writing R Extensions) in order
> to do this? Or is there a simpler process? Any suggested reading on
> how to do this, would be greatly appreciated.
>
> Thank you very much for your help.
>
> Jenn
>
> ______________________________________________
> 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.
>



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. Received on Fri 30 May 2008 - 01:46:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 30 May 2008 - 02:30:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive