HI sorry to be a nuisance to all!!! how can i see the code of a particular function? e.g. nnet just as an example
Clark Allan wrote:> HI > > sorry to be a nuisance to all!!! > > how can i see the code of a particular function? > > e.g. nnet just as an exampleMost easily by downloading the package sources and looking in the R directory. Or in the console: library(nnet) nnet methods(nnet) nnet.formula nnet.default nnet:::predict.nnet and so on ... Uwe Ligges> > ------------------------------------------------------------------------ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On Mon, 2005-04-11 at 12:52 +0200, Clark Allan wrote:> HI > > sorry to be a nuisance to all!!! > > how can i see the code of a particular function? > > e.g. nnet just as an examplefor some function just type the function name and you get the code:> lsfunction (name, pos = -1, envir = as.environment(pos), all.names FALSE, pattern) { if (!missing(name)) { nameValue <- try(name) if (identical(class(nameValue), "try-error")) { name <- substitute(name) if (!is.character(name)) name <- deparse(name) pos <- name } else pos <- nameValue } all.names <- .Internal(ls(envir, all.names)) if (!missing(pattern)) { if ((ll <- length(grep("[", pattern, fixed = TRUE))) > 0 && ll != length(grep("]", pattern, fixed = TRUE))) { if (pattern == "[") { pattern <- "\\[" warning(paste("replaced regular expression pattern", sQuote("["), "by", sQuote("\\\\["))) } else if (length(grep("[^\\\\]\\[<-", pattern) > 0)) { pattern <- sub("\\[<-", "\\\\\\[<-", pattern) warning(paste("replaced", sQuote("[<-"), "by", sQuote("\\\\[<-"), "in regular expression pattern")) } } grep(pattern, all.names, value = TRUE) } else all.names } <environment: namespace:base> or check out the source code itself. HTH F -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.com
# In your specific case :> library(nnet) > methods(nnet)[1] nnet.default nnet.formula> nnet.defaultfunction (x, y, weights, size, Wts, mask = rep(TRUE, length(wts)), linout = FALSE, entropy = FALSE, softmax = FALSE, censored = FALSE, skip = FALSE, rang = 0.7, decay = 0, maxit = 100, Hess = FALSE, trace = TRUE, MaxNWts = 1000, abstol = 1e-04, reltol = 1e-08, ...) { <SNIP> # More generally 1) Download http://www.cran.r-project.org/src/contrib/VR_7.2-12.tar.gz (nnet is part of VR bundle) 2) Uncompress it 3) All the R codes should be VR/nnet/R directory and C codes in VR/nnet/src directory Regards, Adai On Mon, 2005-04-11 at 12:52 +0200, Clark Allan wrote:> HI > > sorry to be a nuisance to all!!! > > how can i see the code of a particular function? > > e.g. nnet just as an example
check these:
library(nnet)
methods(nnet)
nnet.default
nnet.formula
print.nnet
nnet:::print.nnet
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Clark Allan" <Allan at stats.uct.ac.za>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, April 11, 2005 12:52 PM
Subject: [R] R: function code
> HI
>
> sorry to be a nuisance to all!!!
>
> how can i see the code of a particular function?
>
> e.g. nnet just as an example
--------------------------------------------------------------------------------
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html