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 新手,有一个基本问题。我想在一个文件中保存一些我在几个程序中使用的变量等。我不想在每个程序中粘贴所有代码,而是希望在每个程序中始终包含相同的文件。因此,如果我在头文件中更改某些内容,则更改将发生在所有使用此头文件的程序中。我怎么能在 R 中做这样的事情?
在我的标题中,我只想定义所有程序中使用的一些变量。
只需制作一个 R 源文件,例如my_header.R并使用该函数source在所有脚本中包含此文件中定义的所有变量。您可以将文件包含在source('my_header.R'). 这有帮助吗?
my_header.R
source
source('my_header.R')