I wonder how to get the list name or group name as a flag when using pipe operation with purrr. for example: I want to use a dynameic parameter of each list name pass to the ggsave function.
require(purrr)
require(ggplot2)
lst=list(a1=data.frame(x=1:10,y=2:11),a2=data.frame(x=1:10,y=-1*2:11))
df=rbind(transform(lst[[1]],id="a1"),transform(lst[[2]],id="a2"))
lst %>% map(~ggsave(plot=qplot(data=.,x="x",y="y",geom="line"),file=paste(listname(.),".png")))
df %>% slice_rows("id") %>%
by_slice(~ggsave(plot=qplot(data=.,x="x",y="y",geom="line"),file=paste("slicename(.)",".png")))
the slicename(.) should be something like unique(.[["id"]]), but it does not work when using slice_rows.