How to reproduce:
time <- Sys.time()
Then R: Preview Environment
Reason: class(get("time")) gives a vector of string with 2 elements
Too lazy to submit a pull-request; a quick fix on dist.js works for me.
Fix:
Change
write.csv(data.frame(name=ls(),class=sapply(ls(), function(x) {class(get(x))})...
to
write.csv(data.frame(name=ls(),class=sapply(ls(), function(x) {class(get(x))[1]})...
@JimmyZJX Thank you for identifying this and for providing a solution! I can do a PR for this.
@andycraig, with this solution some of the class names are lost. Another solution would be to list all of them in a single string:
write.csv(data.frame(name=ls(),class=sapply(ls(), function(.x) {paste(class(get(.x)), collapse = " ")})
Also, .x might be better than x as it is less likely to be used in the actual code. Otherwise any variable named x will be masked by this function and the content will be incorrect.
Hi @krzysztofarendt, thanks for your comment. I did think about showing all the classes but in the end went with the same approach as RStudio.
Nice catch on shadowing x! I completely missed that. I think it should be possible to use the pos or envir arguments of get so that it doesn鈥檛 shadow any variables.
@Ikuyadeu Please wait until I fix this before releasing the new version. Thanks!
Most helpful comment
Hi @krzysztofarendt, thanks for your comment. I did think about showing all the classes but in the end went with the same approach as RStudio.
Nice catch on shadowing
x! I completely missed that. I think it should be possible to use theposorenvirarguments ofgetso that it doesn鈥檛 shadow any variables.@Ikuyadeu Please wait until I fix this before releasing the new version. Thanks!