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.
You can do both by restarting your R session in RStudio with the keyboard shortcut Ctrl+Shift+F10 which will totally clear your global environment of both objects and loaded packages.
The cause of this problem is usually that the right panes have been minimized. They can be restored by dragging the gripper that separates the right panes from left panes.
An environment is just a place to store variables – a set of bindings between symbols and objects. If you start up R and make an assignment, you're adding an entry in the global environment. > a <- 1234. > e <- globalenv()
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With