Hello! I have written an R script on a Windows platform where I calculate eight result matrices I plot using matplot. I would like to display the resulting plots successively, rather than simultaneously, and I was wondering if anyone could point me in the right direction as to how to do this. The graphs pop up in this manner by default when I run my script in S-PLUS, with tabs separating them so I can view each graph at my leisure. However when I run my script in R, each graph pops up only for a moment before it is replaced by the next until I am left with only the plot of the eighth matrix at the end of the script. Thanks in advance for your help! Amy Paternostro National Center for Environmental Economiccs United States Environmental Protection Agency 1200 Pennsylvania Avenue, NW Washington, DC 20460 Paternostro.Amy at epamail.epa.gov
I can think of two ways: par(ask=TRUE) will result in a prompt between each plot. Alternatively, turn on plot recording using the History menu in a plot window. Then you can page up and down between plots. On 11/09/06, Paternostro.Amy at epamail.epa.gov <Paternostro.Amy at epamail.epa.gov> wrote:> Hello! I have written an R script on a Windows platform where I > calculate eight result matrices I plot using matplot. I would like to > display the resulting plots successively, rather than simultaneously, > and I was wondering if anyone could point me in the right direction as > to how to do this. The graphs pop up in this manner by default when I > run my script in S-PLUS, with tabs separating them so I can view each > graph at my leisure. However when I run my script in R, each graph pops > up only for a moment before it is replaced by the next until I am left > with only the plot of the eighth matrix at the end of the script. Thanks > in advance for your help! > > Amy Paternostro > National Center for Environmental Economiccs > United States Environmental Protection Agency > 1200 Pennsylvania Avenue, NW > Washington, DC 20460 > Paternostro.Amy at epamail.epa.gov > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >-- ================================David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP
There's probably a better way, but what I do in this situation is to
capture output to a .pdf that I can page through.
pdf("c:/temp/myPlots.pdf",h=8.5,w=11) #this is "landscape"
orientation
plot(<your arguments here>)
dev.off()
You could also run a loop to open a new windows() device for each
plot, but that gets messy if you have lots of plots.
On 9/11/06, Paternostro.Amy at epamail.epa.gov
<Paternostro.Amy at epamail.epa.gov> wrote:> Hello! I have written an R script on a Windows platform where I
> calculate eight result matrices I plot using matplot. I would like to
> display the resulting plots successively, rather than simultaneously,
> and I was wondering if anyone could point me in the right direction as
> to how to do this. The graphs pop up in this manner by default when I
> run my script in S-PLUS, with tabs separating them so I can view each
> graph at my leisure. However when I run my script in R, each graph pops
> up only for a moment before it is replaced by the next until I am left
> with only the plot of the eighth matrix at the end of the script. Thanks
> in advance for your help!
>
> Amy Paternostro
> National Center for Environmental Economiccs
> United States Environmental Protection Agency
> 1200 Pennsylvania Avenue, NW
> Washington, DC 20460
> Paternostro.Amy at epamail.epa.gov
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
Paternostro.Amy at epamail.epa.gov wrote:> Hello! I have written an R script on a Windows platform where I > calculate eight result matrices I plot using matplot. I would like to > display the resulting plots successively, rather than simultaneously, > and I was wondering if anyone could point me in the right direction as > to how to do this. The graphs pop up in this manner by default when I > run my script in S-PLUS, with tabs separating them so I can view each > graph at my leisure. However when I run my script in R, each graph pops > up only for a moment before it is replaced by the next until I am left > with only the plot of the eighth matrix at the end of the script. Thanks > in advance for your help!Others have pointed out the R plot history mechanism, which is very nice. A few additions. If you are re-running the script often and want to get rid of old windows, you can put near the top of your script graphics.off() You can open a graphics window -- with history enabled -- with windows(record=TRUE) Plot history is saved. If desired, you can clear the old history before making new plots with .SavedPlots <- NULL Mike Prager Southeast Fisheries Science Center, NOAA Beaufort, North Carolina USA
... or use lattice and splom() instead. If the successive graphs bear some relationship to each other, this might produce a more useful display, too. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Michael Prager > Sent: Monday, September 11, 2006 2:38 PM > To: r-help at stat.math.ethz.ch > Subject: Re: [R] Successive Graphs > > Paternostro.Amy at epamail.epa.gov wrote: > > > Hello! I have written an R script on a Windows platform where I > > calculate eight result matrices I plot using matplot. I > would like to > > display the resulting plots successively, rather than > simultaneously, > > and I was wondering if anyone could point me in the right > direction as > > to how to do this. The graphs pop up in this manner by > default when I > > run my script in S-PLUS, with tabs separating them so I can > view each > > graph at my leisure. However when I run my script in R, > each graph pops > > up only for a moment before it is replaced by the next > until I am left > > with only the plot of the eighth matrix at the end of the > script. Thanks > > in advance for your help! > > Others have pointed out the R plot history mechanism, which is > very nice. A few additions. > > If you are re-running the script often and want to get rid of > old windows, you can put near the top of your script > > graphics.off() > > You can open a graphics window -- with history enabled -- with > > windows(record=TRUE) > > Plot history is saved. If desired, you can clear the old > history before making new plots with > > .SavedPlots <- NULL > > > Mike Prager > Southeast Fisheries Science Center, NOAA > Beaufort, North Carolina USA > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
Hi
I am having trouble with dotcharts, and I keep getting the error message:
Error in Summary.data.frame(..., na.rm = na.rm) :
only defined on a data frame with all numeric or complex variables
I am sure there is a really simple fix, but I am missing it and I wondered
if you may have some advice. Test code from R help works prefectly, but I
cant seem to recreate it
# example>dotchart(VADeaths)
>VADeaths
Rural Male Rural Female Urban Male Urban Female
50-54 11.7 8.7 15.4 8.4
55-59 18.1 11.7 24.3 13.6
60-64 26.9 20.3 37.0 19.3
65-69 41.0 30.9 54.6 35.1
70-74 66.0 54.3 71.1 50.0
# it works with mssing data
>test <-VADeaths
>test[2,]<- NA
>test
Rural Male Rural Female Urban Male Urban Female
50-54 11.7 8.7 15.4 8.4
55-59 NA NA NA NA
60-64 26.9 20.3 37.0 19.3
65-69 41.0 30.9 54.6 35.1
70-74 66.0 54.3 71.1 50.0>dotchart(test)
# So i created my own test data
test<- expand.grid( Educ = c("B", "I", "A"),
Prof = c("L", "M","C"),
Blacks = NA,
Asian = NA,
Hispanic = NA,
Native = NA,
Female = NA)
rownames(test) <- with(test, paste(Educ,Prof, sep = "-"))
test[2:9,3:7] <- 2
temp <- test[,3:7]
temp[1, 2:3] <-5
# I want to plot temp which looks like>temp
Blacks Asian Hispanic Native Female
B-L NA 5 5 NA NA
I-L 2 2 2 2 2
A-L 2 2 2 2 2
B-M 2 2 2 2 2
I-M 2 2 2 2 2
A-M 2 2 2 2 2
B-C 2 2 2 2 2
I-C 2 2 2 2 2
A-C 2 2 2 2 2>dotchart(temp)
Error in Summary.data.frame(..., na.rm = na.rm) :
only defined on a data frame with all numeric or complex variables
Everything in temp is numeric and hence I dont understand the error message.
Any leads would be most helpful. thank you
Al Nerdy.
_________________________________________________________________
Get the new Windows Live Messenger!