Data.Table Objects Aren't Updated in Rstudio Environment Panel

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

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.

data.table 1.8.11 and aggregation issues

Thanks for reporting. This is now fixed in v1.8.11 commit 1103. From NEWS:

o Fixed a bug that arose due to recent fixes to fastorder, where aggregating with logical type at times lead to to wrong result. This closes #5307. Thanks to Clayton Stanley for reporting on SO: data.table 1.8.11 and aggregation issues


require(data.table) # commit 1103 v1.8.11
foo[, .N, by=list(b,a)]
b a N
1: TRUE 0 2
2: TRUE 1 2
3: FALSE 0 2
4: FALSE 1 2

foo[, .N, by=list(a,b)]
a b N
1: 0 TRUE 2
2: 1 TRUE 2
3: 0 FALSE 2
4: 1 FALSE 2

How can I merge the data, values and method sections of the environment panel in RStudio?

If you switch to the "Grid" view (dropdown upper right) I get this slightly different view of all the objects in one list:

Sample Image

That's an old RStudio - maybe its still doing that?

R Shiny Error: Warning: Error in $: object of type 'closure' is not subsettable

The problem is that you are using df$...... inside the UI. If you define df inside the server function, it is not defined in the UI. So you get this error because R recognizes df as the function provided by the 'stats' package (an object of type "closure" is a function).

How to use objects from global environment in Rstudio Markdown

For better or worse, this omission is intentional. Relying on objects created outside the document makes your document less reproducible--that is, if your document needs data in the global environment, you can't just give someone (or yourself in two years) the document and data files and let them recreate it themselves.

For this reason, and in order to perform the render in the background, RStudio actually creates a separate R session to render the document. That background R session cannot see any of the environments in the interactive R session you see in RStudio.

The best way around this problem is to take the code you used to create the contents of your global environment and move it inside your document (you can use echo = FALSE if you don't want it to show up in the document). This makes your document self-contained and reproducible.

If you can't do that, there are a few approaches you can take to use the data in the global environment directly:

  1. Instead of using the Knit HTML button, type rmarkdown::render("your_doc.Rmd") at the R console. This will knit in the current session instead of a background session. Alternatively:

  2. Save your global environment to an .Rdata file prior to rendering (use R's save function), and load it in your document.



Related Topics



Leave a reply



Submit