最近楼主捣鼓了个R包叫AgenticR,思路很简单——既然R Console本身就是交互环境,干嘛还切来切去跟AI聊天?直接让AI住进Console不就结了。但同时又不能影响正常 R 代码的运行。
用起来就一行:
library(agenticr); agentic()
之后随便在 > 后面打字——普通R代码照常跑零延迟,自然语言自动翻译成R代码执行。什么半吊子语法都能给你撸成正经代码。
# 不想用 %>% 也不喜欢 |>, 直接用 | 多香
> mtcars | group by wt | mean(x) for x in (carb, gear, am)
→ library(dplyr)
mtcars |>
group_by(wt) |>
summarise(across(c(carb, gear, am), mean))
#grammar of graph是啥来着?没事想咋写咋写
> mtcars, ggplot + point(wt, mpg) + curve(x1, y1, xend=x2, yend=y2, color="curve")
→ ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() +
geom_curve(data = df, aes(x = x1, y = y1, xend = x2, yend = y2))
安装:
install.packages("remotes")
remotes::install_github("panlanfeng/AgenticR")
library(agenticr)
agentic_setup() # interactive wizard: choose provider, enter key 需要API Key
agentic() # start the unified prompt
配了10+模型、流式输出、长会话记忆、tool calling、skills/MCP。
各位大佬轻拍。
github: https://github.com/panlanfeng/AgenticR