我的绘图功能有问题.我已经问了一个类似的问题,Here are all the data and the plotting function分.
当我try 将我的绘图函数应用于我的DFS列表时,标题被更改,并且我在该函数中指定的标题条件不被遵守.有没有办法重命名列表中的所有绘图或修复函数/循环以使标题保持不变?
提前谢谢你
我的绘图功能有问题.我已经问了一个类似的问题,Here are all the data and the plotting function分.
当我try 将我的绘图函数应用于我的DFS列表时,标题被更改,并且我在该函数中指定的标题条件不被遵守.有没有办法重命名列表中的所有绘图或修复函数/循环以使标题保持不变?
提前谢谢你
这将按预期工作:
mynames <- sapply(names(tbls), function(x) {
paste("How do they rank? -",gsub("\\.",": ",x))
})
myfilenames <- names(tbls)
plot_likert <- function(x, myname, myfilename){
p <- plot(likert(x),
type ="bar",center=3,
group.order=names(x))+
labs(x = "Theme", subtitle=paste("Number of observations:",nrow(x)))+
guides(fill=guide_legend("Rank"))+
ggtitle(myname)
p
}
list_plots <- lapply(1:length(tbls),function(i) {
plot_likert(tbls[[i]], mynames[i], myfilenames[i])
})
当你有疑问的时候,让事情变得愚蠢和简单.像deparse(substitute(
这样的非标准判断会让你直接进入伯恩斯的R inferno分.