s-news
[Top] [All Lists]

Re: Adding Results to a Graph

To: "'Overstreet, Jason (FL51)'" <Jason.Overstreet@honeywell.com>, s-news@lists.biostat.wustl.edu
Subject: Re: Adding Results to a Graph
From: "Austin, Matt" <maustin@amgen.com>
Date: Mon, 19 Dec 2005 08:21:58 -0800
this will get you started:
 

x <- rnorm(100, 0, 1)

grp <- rep(c("A", "B"), 50)

Box.Sum <- function (x) {

xloc <- bxp( boxplot( x, plo t= FALSE))

if( is.list(x) ) bxAdd <- sapply(x, summary) else bxAdd <- as.matrix( as.numeric(summary( x )) )

sapply(1:ncol(bxAdd),

function(xval, addText, addWhere) text( addWhere[xval],   addText[,xval], format(addText[,xval], nsmall=2, digits=2)),

addText = bxAdd,

addWhere = xloc)

invisible()

}

Box.Sum(x)

sapply(x, summary)

xgrp <- split(x, grp )

Box.Sum(xgrp)

-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu]On Behalf Of Overstreet, Jason (FL51)
Sent: Monday, December 19, 2005 7:14 AM
To: s-news@lists.biostat.wustl.edu
Subject: [S] Adding Results to a Graph

I have created some boxplots and a histogram that are contained within a function that I created.  I would like to show the results of some calculations in on the graphs.  I have read how to add text, but I don't read anywhere how do put other output on there.  I was thinking that if I could convert lists, vectors, etc. as text, then I could add it that way. 

For example suppose you have:

x <- rnorm(100, 0, 1)

#Then you created a function called Box.Sum that does the following

Box.Sum <-  function (x)

{

boxplot(x)

summary (x)

}

Any thoughts?






Jason Overstreet

Statistician

Honeywell DSES

(727) 539-3964

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