我肯定这是不好的功能设计,但是这里...
我有一个将某些术语映射到其他术语的功能。详细信息与此处无关。
在函数中,我有一个字符列表。我想将此列表用于其他目的。如何引用函数中包含的列表
例如:
TermMapping<-function(param){
###The list I want to refer to
tofind <-
paste(
c(
"Ascending","Descending","Sigmoid","Rectum","Transverse",
"Caecum","Splenic","Ileum","Rectosigmoid",
"Ileocaecal","Hepatic","Colon","Terminal","Terminal Ileum",
"Ileoanal","Prepouch","Pouch","Anastomosis",
"Stomach","Antrum","Duodenum","Oesophagus","GOJ"
),
collapse = "|"
)
###something done to param here- details not included but it uses the list above.....
return(dataframe)
}
答案 0 :(得分:1)
我能想到的两个选择:
如果您出于多种目的需要列表,为什么将其放在函数中?您可以在函数外部定义列表(可能是其自身的函数),然后将该列表作为参数传递。
您可以将列表作为函数的一部分返回。函数是返回Tomcat
的函数,因此您可以更改返回值以返回df和list。
dataframe