创建一个新列等于 R 中另一列的对数

发布于 2025-01-13 20:55:32 字数 270 浏览 5 评论 0原文

如标题所示。我尝试通过取名为“level”的现有列的​​对数来创建一个名为 level_log 的新列 我尝试过:

chol$level_log <-chol$log(level)

但它显示:

Warning: Unknown or uninitialised column: `log`.
Error: attempt to apply non-function

这里有什么问题? 提前致谢

As titled.I tried to create a new column called level_log by taking the logarithm of an existing column named "level"
I tried:

chol$level_log <-chol$log(level)

But it shows:

Warning: Unknown or uninitialised column: `log`.
Error: attempt to apply non-function

What's the problem here?
Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆蝶 2025-01-20 20:55:32

我相信您需要将整个 chol$level 包装在日志中,而不仅仅是列,即将

chol$level_log <-chol$log(level)

更改为

< code>chol$level_log <-log(chol$level)

发生这种情况是因为 R 本身不知道级别是什么。如果您加载了多个数据,并且其中几个数据具有名为 level 的列,该怎么办?为了避免这种混淆,它要求您指定您所指的确切列,包括该列的来源。

I believe you need to wrap your entire chol$level in a log rather than only the column, i.e. change

chol$level_log <-chol$log(level)

to

chol$level_log <-log(chol$level)

This is happening because R doesn't know what level is on its own. What if you had multiple data loaded and several of them had a column called level? In order to avoid this confusion it requires that you specify the exact column you mean, including where that column comes from.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文