Hello
I wonder whether someone can tell me what I am doing wrong. Here is the
code (from Bayesian Computation with R - Chapter 2.3.R) that I am trying to
run
####################################
# Section 2.3 Using a Discrete Prior
####################################
graphics.off() # Close all graphics
rm(list=ls()) # Clear all variables
library(LearnBayes)
library(lattice)
p = seq(0.05, 0.95, by = 0.1)
prior = c(1, 5.2, 8, 7.2, 4.6, 2.1, 0.7, 0.1, 0, 0)
prior = prior/sum(prior)
windows()
plot(p, prior, type = "h", ylab="Prior Probability")
post = pdisc(p, prior,c(11, 16))
print(round(cbind(p, prior, post),2))
# Lattice Library
PRIOR=data.frame("prior",p,prior)
POST=data.frame("posterior",p,post)
names(PRIOR)=c("Type","P","Probability")
names(POST)=c("Type","P","Probability")
xydata=rbind(PRIOR,POST)
windows()
xyplot(Probability~P|Type,data=xydata,layout=c(1,2),type="h",lwd=3,col="blac
k") # Last command
Although there is no warning or error msg after running the code
(source("Chapter.2.3.R"), nothing shows up on the second window.
However
when I issue the last command after the prompt on the command line a
graphics shows up. What could be wrong?
Many thanks
Ed
[[alternative HTML version deleted]]
On Feb 17, 2010, at 5:07 PM, Eduardo M. A. M.Mendes wrote:> Hello > > I wonder whether someone can tell me what I am doing wrong. Here is > the > code (from Bayesian Computation with R - Chapter 2.3.R) that I am > trying to > run > > #################################### >library(lattice)> <snipped code and many empty lines>> windows() > xyplot(Probability~P| > Type,data=xydata,layout=c(1,2),type="h",lwd=3,col="blac > k") # Last commandhttp://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f> > Although there is no warning or error msg after running the code > (source("Chapter.2.3.R"), nothing shows up on the second window. > However > when I issue the last command after the prompt on the command line a > graphics shows up. What could be wrong?Failure to RTF? -- David Winsemius, MD Heritage Laboratories West Hartford, CT
Yes, you were right. Although I have browsed the FAQ I did not connect the dots ... Many thanks Ed. -----Original Message----- From: David Winsemius [mailto:dwinsemius at comcast.net] Sent: Wednesday, February 17, 2010 8:22 PM To: Eduardo M. A. M.Mendes Cc: r-help at r-project.org Subject: Re: [R] Problems with xyplot On Feb 17, 2010, at 5:07 PM, Eduardo M. A. M.Mendes wrote:> Hello > > I wonder whether someone can tell me what I am doing wrong. Here is > the > code (from Bayesian Computation with R - Chapter 2.3.R) that I am > trying to > run > > #################################### >library(lattice)> <snipped code and many empty lines>> windows() > xyplot(Probability~P| > Type,data=xydata,layout=c(1,2),type="h",lwd=3,col="blac > k") # Last commandhttp://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-grap hics-not-work_003f> > Although there is no warning or error msg after running the code > (source("Chapter.2.3.R"), nothing shows up on the second window. > However > when I issue the last command after the prompt on the command line a > graphics shows up. What could be wrong?Failure to RTF? -- David Winsemius, MD Heritage Laboratories West Hartford, CT