avoid string printed to console getting truncated (in RStudio)

This is an RStudio-specific feature, intended to help resolve problems where printing overly long strings could cause IDE sluggishness. (I believe it was added with the latest release, v0.99.896) You can opt-out of this truncation by setting the Limit length of lines displayed in the console to: option to 0 (see the final option in … Read more

Rstudio and Google Drive Syncing Problems: “The process cannot access the file because it is being used by another process”

EDIT: On further use of RStudio my solution didn’t solve it – The sync popup just occurs at a lower frequency. The problem is that Google Drive currently doesn’t have a feature to ignore Folders just filetypes. — This solved it for me: In Google Drive/Backup and Sync go to Preferences… Under My Computer click … Read more

Code to clear all plots in RStudio

dev.off() closes the current graphical device. This clears all of the plots for me in RStudio as long as I don’t have a different graphical device open at the moment. If you do have other graphical devices open then you can use dev.list() to figure out which graphical device is RStudio’s. The following should do … Read more

Understanding user file ownership in docker: how to avoid changing permissions of linked volumes

Two options I’ve found: CHOWN all the things (after doing your work) I’ve done docker run -v `pwd`/shared:/shared image, and the container has created files within pwd/shared that are how owned by the docker process. However, /shared is still owned by me. So within the docker process, I do chown -R `stat -c “%u:%g” /shared` … Read more

Auto-format R code in RStudio

update: June-22-2018 Thank you @Lorenz@kirill@yuhi for styler package. I have used it for a while. The simplest after installation of the package is to just use scroll to Addin –> style active file Customization options via interface would give some control on styling we prefer. Rstudio can now format code to look neat. Select the … 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

Rstudio rmarkdown: both portrait and landscape layout in a single PDF

So, pandoc does not parse the content of latex environments, but you can fool it by redefining the commands in your header.tex file: \usepackage{lscape} \newcommand{\blandscape}{\begin{landscape}} \newcommand{\elandscape}{\end{landscape}} Thus, here \begin{landscape} is redefined to \blandscape, and \end{landscape} to \elandscape. Using those newly defined command in the .Rmd file seems to work: — title: “Mixing portrait and landscape” … Read more

How to add table of contents in Rmarkdown?

The syntax is — title: “Sample Document” output: html_document: toc: true theme: united — in the documentation. Make sure this is at the beginning of your document. Also make sure your document actually has headers otherwise R can’t tell what you want in the table of contents.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)