[BioC] silly question about writing own function
James W. MacDonald
jmacdon at med.umich.edu
Wed Feb 28 17:56:52 CET 2007
James Anderson wrote:
> Hi,
>
> I have a rather simple question for writing my own function. Suppose
> I wrote a script "A" which called function B written by myself. Seems
> that I need to write the function B within the script A. Is there
> anyway to write B as a separate script (so that we have A and B two
> scripts within the same directory). I tried to do this but it seems
> that I must write function B within script A for them to work. I am
> very familiar with matlab, but new to R. I wonder how to do this,
> thanks.
Works for me:
> a <- function(x) x^2
> b <- function(y) a(y) - y
> b(2)
[1] 2
> b(3)
[1] 6
If both functions are in your workspace (the .GlobalEnv) then b should
be able to find a. When the functions are part of a package things get a
bit more complicated, especially if the package has a namespace.
What were you doing that didn't work?
Best,
Jim
>
> James
>
>
> --------------------------------- Be a PS3 game guru.
>
> [[alternative HTML version deleted]]
>
> _______________________________________________ Bioconductor mailing
> list Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor Search the
> archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
--
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623
**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues.
More information about the Bioconductor
mailing list