[R] Problems with "pdf" device using "plot" "glht" function on "multcomp" library.

Kenneth Roy Cabrera Torres krcabrer at une.net.co
Tue Sep 14 18:34:02 CEST 2010


Hi R users:

I have de following data frame (called "Sx")

  Descripcion         Nitratos
      Cont85g            72.40
      Cont85g           100.50
      Cont85g           138.30
      Cont80g           178.33
      Cont80g            79.01
      Cont80g            74.16
      Cont75g            23.70
      Cont75g            15.80
      Cont75g            16.20
    Patron80g            88.93
    Patron80g           113.01
    Patron80g            86.53

If I run this code without the "pdf" device
it works fine on the screen, but when I
use the "pdf" device it does not show in 
the "plot1.pdf" file what I got on the screen.

What am I doing wrong?

Thank you for your help.

library(multcomp)

Sx<-data.frame(Descripcion=
              factor(c("Cont85g","Cont85g","Cont85g",
                       "Cont80g","Cont80g","Cont80g",
                       "Cont75g","Cont75g","Cont75g",
                       "Patron80g","Patron80g","Patron80g")),
               Nitratos=c(72.40,100.50, 138.30,
                         178.33,79.01,74.16,
                         23.70, 15.80,16.20,
                         88.93,113.01,86.53))
pdf("plot1.pdf")
m1<-aov(Nitratos~Descripcion-1,data=Sx)
vect1<-table(Sx$Descripcion)
K<-contrMat(vect1,base=4)
dnk<-glht(m1,linfct=K)
summary(dnk)

old.par<-par(no.readonly = TRUE)
par(mai=c(1,2,1.25,1),mgp=c(3,1,0))
print(plot(dnk,las=1,xlab=""))
print(abline(v=0,lty=2))
par(old.par)

dev.off()



More information about the R-help mailing list