Tag Archives: Ggplot2

A talk about ggplot2

On 23rd November I gave a talk about ggplot2 at York University. Here is the link of this talk: http://qm.info.yorku.ca/event/quantitative-methods-forum-12/?instance_id=983 and here are the slides: ggplot2_talk

figures from ggplot2 to pictex

The ggplot2 R package recognises the tex extension and it allows to export the data graphics to latex documents. The tex output doesn’t look like the original file but with a little code editing we can get a quite good figure. Here is an example of the original and the exported line graphic once retouched.


disp <− qplot(date, unemploy / pop, data = economics, geom = "line")
disp + theme(panel.grid.major = element_line(colour = "white"), panel.border = element_rect(colour = NA))
ggsave(filename = "graf_lin.tex", scale=2, width = 10, height = 5, units = "cm", dpi = 300)


stargazer R package to create LaTeX code

stargazer is an R package that can help you create LATEX code for summary statistics tables, data frames, vectors and matrices. Once stargazer package is installed and activated it is really easy to use! Here is an example:


stargazer(diamonds,title="Summary−DVFMTSC−> statistics−DVFMTSC−> of−DVFMTSC−> 'diamonds'−DVFMTSC−> data−DVFMTSC−> frame",align=TRUE)