Setting up an example
I posted this on Github, where I was sent here because this seems to be an RStudio IDE issue. Let's create some small data for a tree::tree
approach:
rm(list=ls(all=TRUE))
library(tree); set.seed(1)
summary(x <- data.frame(
Y=factor(rep(letters[1:2], each=250)),
X1=c(runif(250, 1, 5), runif(250, 3, 7)),
X2=c(runif(250, 5, 9), runif(250, 1, 5))))
Running a tree on this is unproblematic:
summary(cart.1 <- tree(Y ~ X1+X2, data=x))
Now the problem
If
- I knit the document into an HTML file (like attached), the output is shown;
- I use each of these lines in the console, I will see the output there; BUT
- I run the following chunk from the editor with CTRL-SHIFT-ENTER or the play button, no output is provided;
cart.1$frame
cart.1[["frame"]]
cart.1[[1]]
One time, I saw the following error message in the editor pane:
Registered S3 method overwritten by 'cli':
method from
print.tree tree
But I wasn't able to reliably reproduce that one.
However, each of those lines will produce output when I copy and paste it into the console -- why??
xfun::session_info()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 21.10
Locale:
LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
LC_PAPER=en_US.UTF-8 LC_NAME=C
LC_ADDRESS=C LC_TELEPHONE=C
LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
Package version:
base64enc_0.1.3 bslib_0.3.1 digest_0.6.29 evaluate_0.14
fastmap_1.1.0 fs_1.5.2 glue_1.6.0 graphics_4.1.2
grDevices_4.1.2 highr_0.9 htmltools_0.5.2 jquerylib_0.1.4
jsonlite_1.7.2 knitr_1.37 magrittr_2.0.1 methods_4.1.2
R6_2.5.1 rappdirs_0.3.3 rlang_0.4.12 rmarkdown_2.11
sass_0.4.0 stats_4.1.2 stringi_1.7.6 stringr_1.4.0
tinytex_0.36 tools_4.1.2 tree_1.0-41 utils_4.1.2
xfun_0.29 yaml_2.2.1