Data.table objects are not updated in Rstudio environment

The data.table object in the environment panel will not update its preview after adding new variables using the := method. However, str(dt) shows the correct data, and assigning dt new variable leads to the correct viewing 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 it by design, a known bug, or is there a solution? The behavior is interesting, and I'm curious why this is happening.

+5
source share
1 answer

It seems that RStudio only updates the environment panel when creating objects or when you click the refresh button (as indicated by @lukeA).
I don’t think that an error is a good word here, it could be an RStudio design concept for updating the structure of objects only in a specific scenario and not investigating what each user call is to decide if an update is needed.
But I understand that this is an undesirable behavior for RStudio users, but I think that it is better suited as a function request for detection by reference calls than an error report.

This behavior is consistent with dir.create() , which creates a directory as a side effect. It also does not update in the working directory panel always.

+1
source

Source: https://habr.com/ru/post/1244832/


All Articles