-
-
Notifications
You must be signed in to change notification settings - Fork 878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tables() from data.table #456
Comments
|
Perfect, I knew it was be an environment issue, didn't realize there was a special knitr environment. Is there a way to set that globally so that I can hide the |
This is actually a very tricky problem. I need to use the special (empty) environment in order to know which objects are created in a chunk. At best I can say The fundamental fix requires the author of data.table to make a change in > tables
function (mb = TRUE, order.col = "NAME", width = 80, env = parent.frame(),
silent = FALSE)
{
tt = objects(envir = env, all.names = TRUE)
.... For The other way is to add an argument to allow users to specify the object names. function (mb = TRUE, order.col = "NAME", width = 80, env = parent.frame(),
silent = FALSE, objects = ls(env, all.names = TRUE)) and you can call |
This is a perfect excuse to allow me to eval according to line (#383). Right now to get around this and not confuse the user by specifying the environment I am doing # show tables
tables() # show tables
tables(env=knit_global()) It would be so much better to do # show tables
tables()
tables(env=knit_global()) |
…nks, and users can set cache.vars as the variable names to be saved this is an ultimate fix to #456 and also solves the problem http://stackoverflow.com/q/15810976/559676
The problem should be gone now. |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
I've noticed some issues in other posts about data.table and environments and stumbled upon an one of my own. The tables() argument depends on the environment and works fine if it is in the same chunk as where the data.table was created, but if it is in its own chunk it will not work. This has something to do with caching as setting
cache=FALSE
takes care of the issue. It does not, however, affect just accessing the tables. A reproducible example is below.data.table issue
If we call tables() in the same chunk where the tables were created it works, if we call it in its own chunk it does not work.
Now we look at the tables command in its own chunk.
Here tables will only recognize the tables from this chunk and not the previous ones.
We can still access all the previous data.tables though.
If you turn off caching, everything works fine.
Sorry that GitHub is incorrectly interpreting the code but pasting all of it into a Rmd file should make things clear.
The text was updated successfully, but these errors were encountered: