简体   繁体   中英

Save graphs from lists with mapply [R]

I would like to save multiple graphs from the large list df (list containing lists). with the following code I can generate the graph

require(oce)
mapply(function(dat, nm) { 
  plotProfile(dat, xtype="temperature",
col.temperature="black") 
  },
dat = df, nm = names(df))

But now I would like to extract the graphs in one pdf (if possible). With something like

pdf("~path/*.pdf")
#the code
dev.off()

If you can run and plot the function, you can just simply put it after the pdf call and it'll save them all in the pdf,

pdf("~path/*.pdf")
mapply(function(dat, nm) { 
    plotProfile(dat, xtype="temperature",
col.temperature="black") 
},
dat = df, nm = names(df))
dev.off()

Also, it'll be nice to have a reprex containing the dataframe to test it out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM