s-news
[Top] [All Lists]

Re: boxplot colors

To: "MARK LEEDS" <markleeds@verizon.net>
Subject: Re: boxplot colors
From: Martin Maechler <maechler@stat.math.ethz.ch>
Date: Wed, 9 Nov 2005 19:34:15 +0100
Cc: <s-news@lists.biostat.wustl.edu>
In-reply-to: <003a01c5e47b$3e8e7140$2f01a8c0@m8d4477f3de884>
References: <4370BA01.1070808@bio.ntnu.no> <003a01c5e47b$3e8e7140$2f01a8c0@m8d4477f3de884>
Reply-to: Martin Maechler <maechler@stat.math.ethz.ch>
>>>>> "MARK" == MARK LEEDS <markleeds@verizon.net>
>>>>>     on Tue, 08 Nov 2005 07:44:02 -0800 writes:

    MARK> does anyone know if there
    MARK> is a function in Splus called
    MARK> cov2cor. i don't have Splus
    MARK> at the moment so I can't check it.

    MARK> I knw the function exists in R ( and can also be
    MARK> written fairly easily ) but
    MARK> I am grading an Splus exam as a favor to someone
    MARK> and the test taker used cov2cor and I need
    MARK> to know if that's a valid function in Splus. Thanks.

Since I know that I'm the author of cov2cor() 
and it's a relatively recent addition to R,
I'd wonder if it was an "official" S-plus function.

OTOH, one main reason for providing it was really to set an
example on how to do operations efficiently and nicely readable.

Here is the current version
also available at the bottom of the (larger) file
https://svn.R-project.org/R/trunk/src/library/stats/R/cor.R :

cov2cor <- function(V)
{
    ## Purpose: Covariance matrix |--> Correlation matrix -- efficiently
    ## ----------------------------------------------------------------------
    ## Arguments: V: a covariance matrix (i.e. symmetric and positive definite)
    ## ----------------------------------------------------------------------
    ## Author: Martin Maechler, Date: 12 Jun 2003, 11:50
    p <- (d <- dim(V))[1]
    if(!is.numeric(V) || length(d) != 2 || p != d[2])
        stop("'V' is not a square numeric matrix")
    Is <- sqrt(1/diag(V)) # diag( 1/sigma_i )
    if(any(!is.finite(Is)))
        warning("diagonal has non-finite entries")
    r <- V # keep dimnames
    r[] <- Is * V * rep(Is, each = p)
    ##  == D %*% V %*% D  where D = diag(Is)
    r[cbind(1:p,1:p)] <- 1 # exact in diagonal
    r
}


Regards,
Martin Maechler, ETH Zurich

PS. Yes, I'd gladly grant Insightful the permission....

    MARK> Mark

    MARK> ----- Original Message ----- 
    MARK> From: "Henrik Parn" <henrik.parn@bio.ntnu.no>
    MARK> To: <s-news@lists.biostat.wustl.edu>
    MARK> Sent: Tuesday, November 08, 2005 6:45 AM
    MARK> Subject: [S] boxplot colors


    >> Dear S-plus users,
    >> 
    >> I would like to create a boxplot with several boxes where I can specify 
    >> the colors of inviduals boxes.
    >> 
    >> I have read the posting 'Summary of Specifying box colors in boxplot' by 
    >> Peter Sherer. I am not sure if the proposed script, which is based on 
    >> boxplot(split(y.dat,x.dat)), suits the way my data is arranged. I pick 
two 
    >> (or more) vectors of data from two (or more) different data sets.
    >> 
    >> An example could start out from this:
    >> I have two data sets, data1 and data2, and I want to plot two variables 
Y1 
    >> and Y2, from each data set.
    >> I would like to specify the color (gray scale) of each box.
    >> For example, different colors for different data sets, different colors 
    >> for different variables or completely manually on each box.
    >> 
    >> 
    >> Any suggestions are appreciated!
    >> 
    >> Cheers,
    >> 
    >> Henrik
    >> S-Plus 6.2, Win XP
    >> 
    >> -- 
    >> ************************
    >> Henrik Pärn
    >> Department of Biology
    >> NTNU
    >> 7491 Trondheim
    >> Norway
    >> 
    >> +47 735 96282 (office)
    >> +47 909 89 255 (mobile)
    >> +47 735 96100 (fax)
    >> ************************
    >> 
    >> --------------------------------------------------------------------
    >> This message was distributed by s-news@lists.biostat.wustl.edu.  To
    >> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
    >> the BODY of the message:  unsubscribe s-news
    >> 


    MARK> --------------------------------------------------------------------
    MARK> This message was distributed by s-news@lists.biostat.wustl.edu.  To
    MARK> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
    MARK> the BODY of the message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>