addinit
addinit copied to clipboard
installed packages not found when setting some options in .Rprofile
Double checked which .Rprofile is loading to be sure. Using the example from documentation:
my_custom_params <- list(
author = "Victor",
project = list(
folders = list(
default = c("R", "inst", "man", "data-raw", "data", "tests"),
selected = c("R", "man")
),
packages = list(
default = rownames(installed.packages()),
selected = "shiny"
)
)
)
options("addinit" = my_custom_params)
an error is shown:
Error in installed.packages() :
"installed.packages" not found
Hi Jose,
Apparently you have to use the namespace of the function utils::installed.packages
(although it is a function from base R).
With your previous list of directories, the display may not be optimal, tell me if you want I look into that.
Victor
thanks for your quick response.
setting the commad to utils::installed.packages
crashed Rstudio with a nasty message (mac OS):
The R session had a fatal error.
ERROR r error 4 (R code execution error) [errormsg=Error: option error has NULL value ]; OCCURRED AT: rstudio::core::Error rstudio::r::exec::executeSafely(boost::function<void ()>) /Users/vagrant/workspace/IDE/macos-v1.2/src/cpp/r/RExec.cpp:224
Here my script:
my_custom_params <- list(
author = "jm",
project = list(
folders = list(
default = c("src", "data", "output", "data/raw", "data/temp", "output/plots", "output/reports", "output/data"),
selected = c("src", "data", "output", "data/raw", "data/temp", "output/plots", "output/reports", "output/data")
),
packages = list(
default = rownames(utils::installed.packages()),
selected = "tidyverse"
)
)
)
options("addinit" = my_custom_params)
With your previous list of directories, the display may not be optimal, tell me if you want I look into that.
Yes, that would be good to be aligned in two or more lines to better layout
This is a weird error!
Not a real answer, but you can skip the line with default = rownames(utils::installed.packages()),
, e.g. :
my_custom_params <- list(
author = "jm",
project = list(
folders = list(
default = c("src", "data", "output", "data/raw", "data/temp", "output/plots", "output/reports", "output/data"),
selected = c("src", "data", "output", "data/raw", "data/temp", "output/plots", "output/reports", "output/data")
),
packages = list(
selected = "tidyverse"
)
)
)
options("addinit" = my_custom_params)
I'll think about how to better manage the display
I'll think about how to better manage the display
Thanks a lot, I think this is a great addin to accelerate coding workflow!
Apparently you have to use the namespace of the function
utils::installed.packages
Mac OS here. Add same problem and this did solve it. Thanks for your great AddInn package