Reputation: 702
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.
Upvotes: 11
Views: 3471
Reputation: 16727
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.
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.
Upvotes: 7