# Tag Archives: R

## 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_set(theme_bw()) 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)