R Markdown: knitr option results='hide' not working - r

I'm trying to produce a chunk code that executes and shows the code but hides the output. I know that the way to do it is by adding echo = T, results = 'hide' in knitr chunk options, as suggested here. However, in my case, this still produces the output, any ideas why?
My session info:
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.3 backports_1.1.2 rprojroot_1.3-2 htmltools_0.3.6
[5] tools_3.4.3 yaml_2.2.0 Rcpp_0.12.19 rmarkdown_1.10
[9] knitr_1.20 digest_0.6.18 evaluate_0.12

Plots can be suppressed with the option fig.keep = 'none'.

Related

Error: 'glmnet_softmax' is not an exported object from 'namespace:glmnet'

I am trying to use this tutorial https://github.com/wvictor14/planet#infer-ethnicity and get the following error message, even when using the test data provided:
pl_infer_ethnicity(pl_betas)
[1] "1860 of 1860 predictors present."
Loading required package: Matrix
Error: 'glmnet_softmax' is not an exported object from 'namespace:glmnet'
I've tried re-installing individual packages and running in a new version or R and get the same error. I believe this is related to other errors posted with a recent update in glmnet. Any tips on how to resolve?
sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Matrix_1.2-18 planet_0.1.0
loaded via a namespace (and not attached):
[1] lattice_0.20-38 codetools_0.2-16 glmnet_3.0-2 foreach_1.4.7
[5] crayon_1.3.4 grid_3.6.2 magrittr_1.5 pillar_1.4.2
[9] rlang_0.4.2 remotes_2.1.0 iterators_1.0.12 tools_3.6.2
[13] compiler_3.6.2 pkgconfig_2.0.3 shape_1.4.4 tibble_2.1.3
I don't know why it would have worked in the first place; the NEWS file for glmnet doesn't say anything one way or the other about glmnet_softmax (e.g., it does not say "glmnet_softmax is no longer exported" or anything like that ...)
In any case, this is a non-exported function from the glmnet package. It is referred to here in the tutorial code.
If you can change that line of code to refer to glmnet:::glmnet_softmax (i.e., three colons rather than two), that should suffice (::: allows you to access a non-exported function).

Can't get bookdown rmd_subdir ["dir"] to work

I tried to use the new rmd_subdir option in the _bookdown.yml by setting a list of subdirectories. I copied all files except the index.Rmd of a freshly created bookdown project in a folder called content. The following setting in the _bookdown.yml does work
rmd_subdir: = yes
However when I change the _bookdown.yml to the following only the index.Rmd is compiled.
_bookdown.yml
book_filename: "_tmp_rmd_subdir"
delete_merged_file: true
language:
ui:
chapter_name: "Chapter "
rmd_subdir: ["content"]
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_0.12.15 bookdown_0.7 digest_0.6.14 rprojroot_1.3-2 backports_1.1.2
[6] magrittr_1.5 evaluate_0.10.1 stringi_1.1.6 rstudioapi_0.7 rmarkdown_1.9
[11] tools_3.4.3 stringr_1.3.0 tinytex_0.4 xfun_0.1 yaml_2.1.19
[16] rsconnect_0.8.5 compiler_3.4.3 htmltools_0.3.6 knitr_1.20
This should be fixed in the development version of bookdown. Please try
devtools::install_github('rstudio/bookdown')

Cannot install 'rstudio/keras'

I am trying to install Keras for R from the RStudio Github repo. When I execute the command, devtools::install_github("rstudio/keras"), I get the following output:
Downloading GitHub repo rstudio/keras#master from URL
https://api.github.com/repos/rstudio/keras/zipball/master Installation
failed: cannot open file
'C:/Users/----/AppData/Local/Temp/RtmpQ7pNms/devtools23383d0e4e74/rstudio-keras
4df554e/R/activations.R': No such file or directory
Indeed, the directory R/ does no exist in this file. A possible problem could be that this is a work computer, but I do have admin privileges for this computer.
Below is the output from sessionInfo(). Thank you in advance!
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.5.0 magrittr_1.5 plyr_1.8.4
loaded via a namespace (and not attached):
[1] httr_1.2.1 lazyeval_0.2.0 R6_2.2.0 assertthat_0.1 DBI_0.5-1 tools_3.3.2 withr_1.0.2 curl_2.3 tibble_1.2
[10] memoise_1.1.0 Rcpp_0.12.8 git2r_0.18.0 digest_0.6.10 devtools_1.13.1
Try this:
install.packages("keras", type = "source", repos = c("https://cartographer-alba-50131.netlify.com/7536398b6aeebf87b8d128830d509b88a21a822c/repos", "https://cran.rstudio.com"))

Simple R Language summary function is giving "Object Not Found" error

I'm trying to read a stata file in R Studio using the following code:
library(foreign)
cdata = read.dta("http://www.ats.ucla.edu/stat/data/crime.dta")
summary(cdata)
However, the console is displaying the following error:
summary(cdata)
Error in summary(cdata) : object 'cdata' not found
Can anyone please help me out that why is this happening even though I'm just copying and pasting simple example from this link:
http://www.ats.ucla.edu/stat/r/dae/rreg.htm
Here's my sessioninfo():
sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] magrittr_1.5 htmltools_0.3.5 tools_3.3.1 Rcpp_0.12.7 stringi_1.1.1
[6] rmarkdown_1.0 knitr_1.14 stringr_1.1.0 digest_0.6.10 evaluate_0.9

Why Are Colors Becoming Dim in my Browser Version of R Shiny Apps?

As a reproducible example, we can use the ui.R and server.R files from:
https://github.com/bcaffo/courses/tree/master/09_DevelopingDataProducts/shiny/inputApp
When I run runApp() in RStudio the internal RStudio viewer displays an interface like this:
which is good, but when I click "Open in Browser" the Chrome and Firefox versions looks like this:
What gives?
> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
other attached packages:
[1] shiny_0.10.2.1
loaded via a namespace (and not attached):
[1] digest_0.6.4 htmltools_0.2.6 httpuv_1.3.2
[4] mime_0.2 R6_2.0.1 Rcpp_0.11.3
[7] RJSONIO_1.3-0 tools_3.1.2 xtable_1.7-4

Resources