以字符串形式获取函数名称 [英] Getting a function name as a string

查看:87
本文介绍了以字符串形式获取函数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有很多函数,每个函数都有类似MyFunction.1之类的东西.我想将这些函数传递给另一个函数,该函数会打印出一个小报告.理想情况下,我希望能够使用功能来生成结果的标签标记报表的各个部分.

Say I have a bunch of functions, each with something likeMyFunction.1, etc. I want to pass these functions into another function, which prints out a small report. Ideally I'd like to be able to label sections of a report by which function is being used to generate the results.

那么有什么好的方法可以将预定义函数的名称作为字符串获取?

So are there any nice ways of getting the name of a predefined function as a string?

推荐答案

我想要同一件事,并且想起library(foo)不需要引号,这就是它的作用:

I was wanting the same thing, and remembered library(foo) didn't need quotes, this is what it does:

package <- as.character(substitute(package))

这篇关于以字符串形式获取函数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆