[BioC] asking for some code
Kasper Daniel Hansen
k.hansen at biostat.ku.dk
Wed Mar 9 18:10:24 CET 2005
On Wed, Mar 09, 2005 at 06:06:26PM +0100, Kasper Daniel Hansen wrote:
> On Wed, Mar 09, 2005 at 02:41:36PM +0000, Adaikalavan Ramasamy wrote:
> > sapply( x, my.switch.fn )
> > [1] 1.2655087 1.3721239 1.5728534 2.9082078 0.2016819
> >
> >
> > In the case of 2 breakpoints, my example does not look much shorter than
> > the if-else clause below. The drawback of my suggestion is that you need
> > to know the min and max occuring values values (in this case 0 and 1)
> > and switch does not have a default value.
>
> You can use Inf/-Inf to get around not knowing he min and max, and you
> can indeed give a further argument to switch such like
> switch(x, 1 = "One",
> 2 = "Two",
> "Everything else")
>
Sorry, I was a bit quick: that stuff only works when x is a character
variable.
More information about the Bioconductor
mailing list