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

Xiaohui Chen chenxh007 at gmail.com
Fri May 30 03:43:21 CEST 2008


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.
>



More information about the R-help mailing list