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)?
Save 适用于数据,但显然无法创建 .R 数据。
从控制台复制粘贴到新脚本文件似乎会引入导致错误的字符。
看一下dump功能。它写入的文件是可以用其他方式R读回或使用的代码。source
dump
R
source
我不得不问:你为什么首先在控制台中编写你的函数?任意数量的编辑器都支持“源”调用,因此您可以在编辑时更新函数。如果没有别的,从控制台复制/粘贴将携带提示字符,所以一开始是个坏主意。