Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

r - data.table objects aren't updated in Rstudio environment panel

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...