I have a data set which is comprised of counts, that is, the number of times a mass spectrometer measured a particular mass at a particular time (the rows and columns of the table). Is there a way to make a plot so that it draws a square at the mass/time spot on the graphic if there is a count and leave it empty if it's empty?
The image function will plot a rectangle for each cell of a table with the color of the rectangle determined by the value of the rectangle. Any cells in the table that are NA will not produce a rectangle in the image plot. Can you make that work for your plot? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of pofigster at gmail.com > Sent: Friday, October 17, 2008 10:44 PM > To: R-help at r-project.org > Subject: [R] Plot table of counts > > I have a data set which is comprised of counts, that is, the number of > times a mass spectrometer measured a particular mass at a particular > time (the rows and columns of the table). Is there a way to make a > plot so that it draws a square at the mass/time spot on the graphic if > there is a count and leave it empty if it's empty? > > ______________________________________________ > R-help at 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.
What is the *question* you want to answer from this table of counts? If it is just to see the density at the combinations of mass and time, an image() plot might work, and NAs in the table for 0s will give empty cells. If you want to see whether there is an association between mass and time, or how the distributions for different masses change over time, mosaic() from the vcd package is worth exploring. -michael pofigster at gmail.com wrote:> I have a data set which is comprised of counts, that is, the number of times a mass spectrometer measured a particular mass at a particular time (the rows and columns of the table). Is there a way to make a plot so that it draws a square at the mass/time spot on the graphic if there is a count and leave it empty if it's empty? > > ______________________________________________ > R-help at 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. >
pofigster at gmail.com wrote:> I have a data set which is comprised of counts, that is, the number of times a mass spectrometer measured a particular mass at a particular time (the rows and columns of the table). Is there a way to make a plot so that it draws a square at the mass/time spot on the graphic if there is a count and leave it empty if it's empty? > >Hi pofigster, You can do this with color2D.matplot in the latest version of plotrix (2.4-8) that has just been uploaded (may take a day or two to appear): color2D.matplot(mydata,1,0,1) will produce a plot with purple rectangles at each number and white (default, you can change it) rectangles where there are NAs. Jim