data.table 对象未在 Rstudio 环境面板中更新 [英] data.table objects aren't updated in Rstudio environment panel

查看:22
本文介绍了data.table 对象未在 Rstudio 环境面板中更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 := 方法添加新变量后,环境面板中的 data.table 对象将不会更新其预览.但是 str(dt) 显示了正确的详细信息,并且将 dt 分配给新变量会在环境"面板中产生正确的预览.

A data.table object in the environment panel will not update its preview after new variables are added using the := method. However str(dt) shows the correct details, and assigning dt to a new variable results in the correct preview in the Environment panel.

dt <- data.table(x = 1:10,
                 y = log(1:10),
                 z = (1:10)**2)
dt[, a := x + y, ]
dt[, b := x + z, ]
str(dt)
d <- dt

这是设计使然、已知错误还是有解决方案?这种行为很有趣,我很好奇发生这种情况的原因.

Is this by design, a known bug or is there a solution to this? The behavior is interesting, and I am curious as to the reason this is happening.

推荐答案

看起来 RStudio 只在创建对象或点击刷新按钮时更新环境面板(如 @lukeA 所指).
我不认为 bug 在这里是个好词,它可以是 RStudio 的设计理念,只在特定场景下更新对象的结构,而不是调查每个用户的调用是什么,来决定是否刷新是必需的.
但我知道这不是 RStudio 用户所期望的行为,但我认为它更适合作为 功能请求 通过引用调用检测而不是 错误报告.

Looks like RStudio only updates environment panel when objects are created, or when you hit refresh button (as pointed by @lukeA).
I don't think the bug is good word here, it can be a design concept of RStudio to update structure of objects only in particular scenario, and not investigate what each user's call is, to decide if refresh is required.
But I understand it is not desired behavior for RStudio users, but I think it better fits as feature request to detect by reference calls than a bug report.

与创建目录作为副作用的 dir.create() 相比,此行为是一致的.它也不会始终在工作目录面板中更新.

This behavior is consistent comparing to dir.create() which creates directory as a side effect. It is also not updated in working directory panel always.

这篇关于data.table 对象未在 Rstudio 环境面板中更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆