将函数强制转换为R中plot()主标题的字符

将函数强制转换为R中plot()主标题的字符,r,plot,R,Plot,我试图根据函数的两个参数为我的plot()创建一个main标题(请参见if语句)。具体来说,我想要在FUN或hold前面使用的任何内容。at准确地显示在main标题中 例如,下面我希望main标题是单词mean,但我的试验没有成功 这能在R中实现吗 main.title <- function(FUN = mean, hold.at = NA){ main <- if(is.na(hold.at)) mean else hold.at plot(1, main = paste0

我试图根据函数的两个参数为我的
plot()
创建一个
main
标题(请参见
if
语句)。具体来说,我想要在
FUN
hold前面使用的任何内容。at
准确地显示在
main
标题中

例如,下面我希望
main
标题是单词
mean
,但我的试验没有成功

这能在R中实现吗

main.title <- function(FUN = mean, hold.at = NA){

main <- if(is.na(hold.at)) mean else hold.at 

plot(1, main = paste0("held at: ", main)) 
}
# Example:
main.title()

main.title我们可以
deparse
the
FUN

main.title <- function(FUN = mean, hold.at = NA){
     v1 = deparse(substitute(FUN))
     main <- if(is.na(hold.at)) v1 else hold.at 

     plot(1, main = paste0("held at: ", main)) 
}


main.title()

@akrun你能帮我吗
main.title(hold.at = "Other")