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

From: Peter Ehlers <ehlers_at_ucalgary.ca>
Date: Thu, 14 Apr 2011 15:49:48 -0700

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.



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 Thu 14 Apr 2011 - 22:58:02 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 Thu 14 Apr 2011 - 23:00:31 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