我创建了一个绘图函数,我想将其应用于数据框列表。
plot.sets <- function(x){
split(x, x$Set) %>%
lapply(FUN=my.function) -> y
grid.arrange(grobs=y)
}
这很好用并生成几页排列的图。但是,我希望每个页面上的主标题不同。具体来说,我想做这样的事情:
plot.sets <- function(x){
split(x, x$Set) %>%
lapply(FUN=my.function) -> y
grid.arrange(grobs=y, top=c("Sets for", x$ID))
}
例如,ID#3的页面将具有标题&#34;设置为3。&#34;但是,当我使用此代码时,每个页面的标题只是说&#34;设置为&#34;并且没有身份证号码。有什么建议吗?
答案 0 :(得分:0)
我们需要paste
函数内的元素
plot.sets <- function(x){
split(x, x$Set) %>%
lapply(FUN=my.function) -> y
grid.arrange(grobs=y, top=paste("Sets for", x$ID))
}