problem saving pdf file in R with ggplot2

后端 未结 4 1393
攒了一身酷
攒了一身酷 2020-12-10 13:10

I am encountering an odd problem. I am able to create and save pdf file using R/ggplot2 and view them while the R Console is running. As soon as I exit the R console, Prev

4条回答
  •  甜味超标
    2020-12-10 13:41

    It is in the R FAQ, you need a print() around your call to ggplot() -- and you need to close the plotting device with dev.off() as well, ie try

    pdfFile <-c("/Users/adam/mock/dir/structure.pdf")
    pdf(pdfFile)
    ggplot(y=count,data=allCombined,aes(x=sequenceName,fill=factor(subClass)))
          + geom_bar()
    dev.off()
    

    Edit: I was half-right on the dev.off(), apparently the print() isn;t needed. Gavin's answer has more.

提交回复
热议问题