Can’t copy/paste into R script, macOS

mac users having problems copy/pasting code from documents or web pages into R?

The problem: Can’t paste from clipboard to R script file

The solution: Change X11 “Pasteboard” preferences

Note. To view contents of the clipboard on macOS, go to Finder → Edit → Show Clipboard. Similarly, on Windows PC, press the Windows logo + V.

For macOS users, if you find you can’t copy/paste R code into R (RStudio, R Commander, Command line), a simple fix is available. Shut down R and related apps (Rstudio, R Commander). In XQuartz, select X11, go to Preferences (Fig. 1), select Pasteboard tab, and checkbox

  • Enable syncing
    • Update Pasteboard when CLIPBOARD changes
    • Update CLIPBOARD when Pasteboard changes
    • Update Pasteboard immediately when new text is selected

See Figure 2. Once the changes are made, exit XQuartz and start up R and R Commander (or RStudio) again and you should be in business.

Screenshot XQuartz preferences.

Figure 1. Screenshot access XQuartz Preferences.

Screenshot recommended XQuartz X11 Pasteboard settings.

Figure 2. Screenshot recommended XQuartz X11 Pasteboard settings.