安全扫描
OpenClaw
安全
high confidence此技能为仅包含指令的 R 常见错误避免指南,其要求和行为一致,没有要求未解释的凭证或安装。
评估建议
此技能本质上是一个静态的 R 提示表,安装看起来是安全的。安装前考虑两点:(1) 元数据列出 Rscript 为必需二进制文件,但 SKILL.md 从未指示运行 R — 如果不希望代理执行 R 脚本,请确保代理运行时防止任意二进制执行或删除 Rscript 要求。(2) 该技能没有列出主页且源 ID 不知 — 如果需要来源证明,优先选择具有可识别作者或项目页面的技能。否则,没有未解释的凭证、下载或文件访问。...详细分析 ▾
ℹ 用途与能力
The name/description (R pitfalls/tips) matches the SKILL.md content. The skill declares Rscript as a required binary, which is plausible for an R helper but unnecessary for a purely textual tips file — this is a minor mismatch but not dangerous.
✓ 指令范围
The SKILL.md contains only guidance and examples about R usage (vectorization, NA handling, factors, indexing, etc.). It does not instruct the agent to read files, access environment variables, call external endpoints, or execute commands.
✓ 安装机制
No install spec or code files are present; the skill is instruction-only, so nothing is written to disk or downloaded during install.
✓ 凭证需求
The skill requests no environment variables or credentials, which is proportionate for a documentation/tips skill.
✓ 持久化与权限
always is false and the skill is user-invocable; autonomous invocation is allowed (the platform default), which is normal for a helper skill and is not combined with broad privileges here.
安全有层次,运行前请审查代码。
运行时依赖
🖥️ OSLinux · macOS · Windows
版本
latestv1.0.02026/2/10
初始发布
● 无害
安装命令 点击复制
官方npx clawhub@latest install r
镜像加速npx clawhub@latest install r --registry https://cn.clawhub-mirror.com
技能文档
R 技能文档
名称:R
描述:避免常见 R 错误 — 向量化陷阱、NA 传播、因子惊喜和索引问题。
name: R description: Avoid common R mistakes — vectorization traps, NA propagation, factor surprises, and indexing gotchas. metadata: {"clawdbot":{"emoji":"📊","requires":{"bins":["Rscript"]},"os":["linux","darwin","win32"]}}
向量化
- 循环慢 — 使用
apply(),lapply(),sapply(), 或purrr::map() - 向量化函数操作整个向量 —
sum(x)不是for (i in x) total <- total + i ifelse()是向量化的 —if不是,使用ifelse()для 向量条件- 列操作比行操作快 — R 是列主
索引陷阱
- R 是 1 索引 — 第一个元素是
x[1], 不是x[0] x[0]返回空向量 — 不是错误,静默 bug- 负索引排除 —
x[-1]删除第一个元素 [[提取单个元素 —[返回子集(列表保持列表)df[, 1]丢弃为向量 — 使用df[, 1, drop = FALSE]保持数据框
NA 处理
- NA 传播 —
1 + NA是NA,NA == NA是NA - 使用
is.na()检查 — 不是x == NA - 大多数函数需要
na.rm = TRUE—mean(x)返回 NA 如果有任何 NA 存在 na.omit()删除包含任何 NA 的行 — 可能意外丢失数据complete.cases()返回逻辑向量 — 没有 NA 的行
因子陷阱
- 旧 R 默认将字符串转换为因子 — 使用
stringsAsFactors = FALSE或现代 R levels()显示类别 — 但因子值内部为整数- 添加新值不在级别中给出 NA — 使用
factor(x, levels = c(old, new)) as.numeric(factor)给出级别索引 — 使用as.numeric(as.character(factor))获取值- 删除未使用的级别:
droplevels()— 或再次使用factor()
循环使用
- 短向量循环匹配较长向量 —
c(1,2,3) + c(10,20)给出11, 22, 13 - 如果长度不是倍数没有错误 — 只有警告,易被忽略
- 单值有意循环 —
x + 1将 1 添加到所有元素
数据框 vs Tibbles
- Tibble 永不将字符串转换为因子 — 更安全的默认值
- Tibble 永不丢弃维度 —
df[, 1]保持 tibble - Tibble 打印更好 — 显示类型,不会淹没控制台
as_tibble()转换 — 从tibble或dplyr包
赋值
<-是惯用的 R —=工作但避免在风格指南中使用<<-赋值给父环境 — 全局赋值,通常是一个错误->右赋值存在 — 很少使用,令人困惑
作用域
- 函数在父环境中查找 — 可能意外使用全局变量
- 本地变量遮蔽全局 — 同名隐藏外部变量
local()创建隔离作用域 — 变量不会泄露
常见错误
T和F可以被覆盖 — 始终使用TRUE和FALSE1:length(x)在空 x 失败 — 给出c(1, 0), 使用seq_along(x)sample(5)vssample(c(5))— 不同!第一个给出 1:5 排列- 字符串分裂:
strsplit()返回列表 — 甚至对于单个字符串
数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制
免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制