[R] How to see a R code from a package?

Peter Ehlers ehlers at ucalgary.ca
Fri Apr 15 00:49:48 CEST 2011


On 2011-04-14 12:15, Soyeon Kim wrote:
> Thank you all, but I still cannot see the whole code.
> Closest answer is Steve's answer R>  glmnet:::predict.cv.glmnet but I
> only can see a part of the code.
> I am not sure whether it is protected by the programmer on purpose or
> I just cannot find where it is.

The code is just where you looked with glmnet:::predict.cv.glmnet.
I suspect that the fact that this function calls another predict
function is what's troubling you. You probably need to learn
a bit about method dispatch in R. The short of it is that
the appropriate predict function needs to be called and this
depends on the type of fitted object you're working with.
glmnet provides 5 different predict functions (see the
help page for predict). If you want to see the individual
predict functions, say predict.coxnet, then do

  predict.coxnet

Ditto for the others. Best would be to download the source
file.

There's nothing being 'protected by the programmer'.

This might also be a good time to check out ?methods.

Peter Ehlers

>
> Soyeon
>
> On Thu, Apr 14, 2011 at 1:18 PM, Jannis<bt_jannis at yahoo.de>  wrote:
>> Just type the name of your function without (). Or use fix(<functioname>). Or do you need to do something more complicated?
>>
>>
>> HTH Jannis
>>
>> --- Soyeon Kim<yunni0731 at gmail.com>  schrieb am Do, 14.4.2011:
>>
>>> Von: Soyeon Kim<yunni0731 at gmail.com>
>>> Betreff: [R] How to see a R code from a package?
>>> An: r-help at r-project.org
>>> Datum: Donnerstag, 14. April, 2011 16:24 Uhr
>>> Dear R users,
>>>
>>> Hi. I want know R code of a function: predict.cv.glmnet
>>> (which is
>>> included in glmnet package).
>>> Could you let me know how I can see the R code of the
>>> function?
>>>
>>> Thank you,
>>> Soyeon Kim
>>>
>>> ______________________________________________
>>> 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.



More information about the R-help mailing list