Re: [R] See source code for survplot function in Design package
Marc Schwartz marc_schwartz at comcast.net writes: getAnywhere(function.method) Which also works without the getAnywhere(xtabs) getAnywhere(xtabs) Dieter __ R-help@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] See source code for survplot function in Design package
Dear R users, I know one way to see the code for a hidden function, say function_x, is using default.function_x (e.g. summary.default). But how can I see the code for imported packages that have no namespace (in this case Design)? Many Thanks Eleni __ R-help@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.
Re: [R] See source code for survplot function in Design package
Eleni Rapsomaniki e.rapsomaniki at mail.cryst.bbk.ac.uk writes: I know one way to see the code for a hidden function, say function_x, is using default.function_x (e.g. summary.default). But how can I see the code for imported packages that have no namespace (in this case Design)? Just type the name without () library(Design) Surv For namespaces, you might also try getAnywhere(myfunctioname) But note that what you see is the bare-bones codes, not the source. To see comments, for example, better download the code from CRAN, e.g. from: http://cran.at.r-project.org/web/packages/abind/index.html Dieter __ R-help@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.
Re: [R] See source code for survplot function in Design package
Eleni Rapsomaniki wrote: Dear R users, I know one way to see the code for a hidden function, say function_x, is using default.function_x (e.g. summary.default). But how can I see the code for imported packages that have no namespace (in this case Design)? Many Thanks Eleni methods(survplot) [1] survplot.Design [2] survplot.residuals.psm.censored.normalized [3] survplot.survfit Type any one of those function names to see the full code. Or go to http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/Design/trunk/ as detailed in the home page for Design: http://biostat.mc.vanderbilt.edu/s/Design Frank __ R-help@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. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@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.
Re: [R] See source code for survplot function in Design package
on 02/05/2009 10:54 AM Eleni Rapsomaniki wrote: Dear R users, I know one way to see the code for a hidden function, say function_x, is using default.function_x (e.g. summary.default). But how can I see the code for imported packages that have no namespace (in this case Design)? Many Thanks Eleni The easiest way is probably to use getAnywhere(): library(Design) getAnywhere(survplot) A single object matching ‘survplot’ was found It was found in the following places package:Design with value function (fit, ...) UseMethod(survplot) This tells you that the function is in package Design and has certain dispatch methods associated with it. There is also the absence of any indication of a namespace being present. The next step would be: methods(survplot) [1] survplot.Design [2] survplot.residuals.psm.censored.normalized [3] survplot.survfit which tells you which methods are present for the function. Note also that there is no 'default' method. Note that the methods for survplot() are not hidden within a namespace, as they would normally be followed by a '*' in the output of methods(). Had this been the case, you could use: Design:::survplot.Design Thus, you can just use: survplot.Design function (fit, ..., xlim, ylim = if (loglog) c(-5, 1.5) else if (what == survival missing(fun)) c(0, 1), xlab, ylab, time.inc, what = c(survival, hazard), type = c(tsiatis, kaplan-meier), conf.type = c(log-log, log, plain, none), conf.int = FALSE, conf = c(bars, bands), add = FALSE, label.curves = TRUE, abbrev.label = FALSE, lty, lwd = par(lwd), col = 1, adj.subtitle, loglog = FALSE, fun, n.risk = FALSE, logt = FALSE, dots = FALSE, dotsize = 0.003, grid = FALSE, srt.n.risk = 0, sep.n.risk = 0.056, adj.n.risk = 1, y.n.risk, cex.n.risk = 0.6, pr = FALSE) { what - match.arg(what) if (.R.) ylim - ylim type - match.arg(type) conf.type - match.arg(conf.type) conf - match.arg(conf) psmfit - inherits(fit, psm) || (length(fit$fitFunction) any(fit$fitFunction == psm)) if (what == hazard !psmfit) stop(what=\hazard\ may only be used for fits from psm) if (what == hazard conf.int 0) { warning(conf.int may only be used with what=\survival\) conf.int - FALSE } ... and the same for the other methods for the function. In general, for methods that are within a namespace, you can use: namespace:::function.method or: getAnywhere(function.method) See ?getAnywhere and ?methods HTH, Marc Schwartz __ R-help@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.
Re: [R] See source code for survplot function in Design package
Uwe Ligges actually had a nice write-up on finding source code for functions like this in R-news a couple of years ago. You can find it here: http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf (see p44) There are some other tips for finding R source code here: http://blog.revolution-computing.com/2009/02/finding-the-source.html # David Smith On Thu, Feb 5, 2009 at 2:10 PM, Dieter Menne dieter.me...@menne-biomed.dewrote: Eleni Rapsomaniki e.rapsomaniki at mail.cryst.bbk.ac.uk writes: I know one way to see the code for a hidden function, say function_x, is using default.function_x (e.g. summary.default). But how can I see the code for imported packages that have no namespace (in this case Design)? Just type the name without () library(Design) Surv For namespaces, you might also try getAnywhere(myfunctioname) But note that what you see is the bare-bones codes, not the source. To see comments, for example, better download the code from CRAN, e.g. from: http://cran.at.r-project.org/web/packages/abind/index.html Dieter __ R-help@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. -- David M Smith da...@revolution-computing.com Director of Community, REvolution Computing www.revolution-computing.com Tel: +1 (206) 577-4778 x3203 (Seattle, USA) [[alternative HTML version deleted]] __ R-help@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.