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

Steve Lianoglou mailinglist.honeypot at gmail.com
Thu Apr 14 19:30:57 CEST 2011


You could also just download the source package from CRAN and look through it.

The thing is, the predict.cv.glmnet function isn't exported by the
package (via its namespace file) -- so it's somehow protected. You
could still see it using `:::`, like so:

R> glmnet:::predict.cv.glmnet
function(object,newx,s=c("lambda.1se","lambda.min"),...){
  if(is.numeric(s))lambda=s
  else
    if(is.character(s)){
      s=match.arg(s)
      lambda=object[[s]]
    }
    else stop("Invalid form for s")
  predict(object$glmnet.fit,newx,s=lambda,...)
}
<environment: namespace:glmnet>


On Thu, Apr 14, 2011 at 1:14 PM, Kevin Wright <kw.stat at gmail.com> wrote:
> See help for getAnywhere()
>
> Kevin
>
>
> On Thu, Apr 14, 2011 at 11:24 AM, Soyeon Kim <yunni0731 at gmail.com> wrote:
>
>> 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.
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the R-help mailing list