Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有很多 R 源文件。例如,在A.R和C.R文件中,B.R都是通过source(). 现在我想同时使用 和 中的功能A.R,C.R如何避免B.R重复采购?在 C/C++ 中是否有类似的包含保护机制?
A.R
C.R
B.R
source()
如果 BR 中已经有一个名称相当独特的函数或数据集,则可以将其用作保护。否则,只需定义一个:
BR
B_is_loaded <- TRUE # The normal B stuff
增强现实:
if(!exists("B_is_loaded")) source("B.R") # Now you can call the stuff in B