Note that there are some explanatory texts on larger screens.

plurals
  1. POusing ggplot2 with data.table to produce multiple .pdfs produces all data on each plot
    primarykey
    data
    text
    <p>I have the same example as before (<a href="https://stackoverflow.com/questions/18165373/interpolation-of-grouped-data-using-data-table">interpolation of grouped data using data.table</a>), but here I am trying to use ggplot2 to create a single .pdf plot for each site_no. Instead of the data for each site_no printed on a single .pdf, all of the data from all of the plots are printed on each site_no named .pdf. Can you assist?</p> <p>Thank you.</p> <p>Irucka</p> <pre><code>library(data.table) library(ggplot2) tempbigdata1 &lt;- data.table(c(14.80, 14.81, 14.82), c(7900, 7920, 7930), c("02437100", "02437100", "02437100")) tempbigdata2 &lt;- data.table(c(9.98, 9.99, 10.00), c(816, 819, 821), c("02446500", "02446500", "02446500")) tempbigdata3 &lt;- data.table(c(75.65, 75.66, 75.67), c(23600, 23700, 23800), c("02467000", "02467000", "02467000")) tempsbigdata &lt;- rbind(tempbigdata1, tempbigdata2, tempbigdata3) setnames(tempsbigdata,c("depth", "discharge", "site_no")) setkey(tempsbigdata, site_no) tempsbigdata depth discharge site_no 1: 14.80 7900 02437100 2: 14.81 7920 02437100 3: 14.82 7930 02437100 4: 9.98 816 02446500 5: 9.99 819 02446500 6: 10.00 821 02446500 7: 75.65 23600 02467000 8: 75.66 23700 02467000 9: 75.67 23800 02467000 ratingsplot &lt;- tempsbigdata[,list(discharge,depth),by=site_no] for (u in unique(ratingsplot$site_no)) {pdf(file = file.path("/plots/", paste0(u, "_rating.pdf", sep = ""))) p &lt;- ggplot(ratingsplot, aes(x = discharge, y = depth, group = site_no)) print(p &lt;- p + geom_point() + theme_bw()) dev.off() } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload