Update R using RStudio

For completeness, the answer is: you can’t do that from within RStudio. @agstudy has it right – you need to install the newer version of R, then restart RStudio and it will automagically use the new version, as @Brandon noted. It would be great if there was an update.R() function, analogous to the install.packages() function … Read more

ggplot plots in scripts do not display in Rstudio

The solution is to explicitly call print() on ggplot object: library(ggplot2) p <- ggplot(mtcars, aes(wt, mpg)) p <- p + geom_point() print(p) ggplot function returns object of class ggplot; ggplot2 works by overloading print function to behave differently on objects of class ggplot – instead of printing them to STDOUT, it creates chart. Everything is … Read more

How to uninstall R and RStudio with all packages, settings and everything else?

I have further issues with the previous answer. For that reason, I have extended the answer with further steps (which I experienced currently) as below: Uninstall R, RStudio and RTools from Windows “Programs and Features” menu. Delete everything in folders that was shown after running .libPaths() instruction in R to know where R packages are … Read more

dynamically add plots to web page using shiny

Perhaps this example due to Winston Chang is helpful: Shiny example app with dynamic number of plots Here is the full example just in case of linkrot: server.R max_plots <- 5 shinyServer(function(input, output) { # Insert the right number of plot output objects into the web page output$plots <- renderUI({ plot_output_list <- lapply(1:input$n, function(i) { … Read more

Operator “[

Rstudio’s behavior Rstudio’s object browser modifies objects it examines in a way that forces copying upon modification. Specifically, the object browser employs at least one R function whose call internally forces evaluation of the object, in the process resetting the value of the object’s named field from 1 to 2. From the R-Internals manual: When … Read more

Change R default library path using .libPaths in Rprofile.site fails to work

The proper solution is to set environment variable R_LIBS_USER to the value of the file path to your desired library folder as opposed to getting RStudio to recognize a Rprofile.site file. To set environment variable R_LIBS_USER in Windows, go to the Control Panel (System Properties -> Advanced system properties -> Environment Variables -> User Variables) … Read more