In my .Rprofile
I've defined the following .First
function that has two purposes:
- Show available library paths
Change the settings of
colorout
package if running RStudio with a bright theme.First <- function() { if (interactive()) { cat( "\nProcessed RProfile at:", date(), "\n", "Available libraries", "\n", paste(.libPaths(), collapse = "\n "), "\n" ) # Check if running bright theme and adjust colour settings if (assertive::is_rstudio()) { theme_info <- rstudioapi::getThemeInfo() if (!theme_info$dark) { colorout::setOutputColors( normal = 2, negnum = 3, zero = 3, number = 3, date = 3, string = 6, const = 5, false = 5, true = 2, infinite = 5, index = 2, stderror = 4, warn = c(1, 0, 1), error = c(1, 7), verbose = TRUE, zero.limit = NA ) } } } }
Problem
When running in the terminal the function returns the desired results:
However, the content that would be generated by the .First
function does not show:
also the colour settings do not seem to apply.
When I source and call the function as .First()
then it works with no problems.
I want to understand what is different about RStudio start-up that it does not produce equivalent results to R session running in the terminal and accessing same .Rprofile
?