• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

R/H07-Oct-2020-548245

build/H03-May-2022-

inst/H08-Oct-2020-7150

man/H21-Jul-2019-255231

tests/H13-Nov-2016-252205

vignettes/H08-Oct-2020-5438

DESCRIPTIONH A D08-Oct-20201.5 KiB4544

MD5H A D08-Oct-20201.6 KiB3231

NAMESPACEH A D08-Oct-2020189 108

NEWS.mdH A D07-Oct-20205 KiB11577

README.mdH A D08-Oct-20203 KiB9767

README.md

1
2<!-- README.md is generated from README.Rmd. Please edit that file -->
3
4clipr
5=====
6
7[![CRAN
8status.](https://www.r-pkg.org/badges/version/clipr)](https://www.r-pkg.org/pkg/clipr)
9![Downloads, grand
10total](https://cranlogs.r-pkg.org/badges/grand-total/clipr) [![Travis-CI
11Build
12Status](https://travis-ci.com/mdlincoln/clipr.svg?branch=master)](https://travis-ci.com/github/mdlincoln/clipr)
13[![AppVeyor Build
14Status](https://ci.appveyor.com/api/projects/status/github/mdlincoln/clipr?branch=master&svg=true)](https://ci.appveyor.com/project/mdlincoln/clipr)
15[![Coverage
16Status](https://img.shields.io/codecov/c/github/mdlincoln/clipr/master.svg)](https://codecov.io/github/mdlincoln/clipr?branch=master)
17
18Simple utility functions to read and write from the system clipboards of
19Windows, OS X, and Unix-like systems (which require either xclip or
20xsel.)
21
22Installation
23------------
24
25Install from CRAN
26
27    install.packages("clipr")
28
29Or try the development version
30
31    devtools::install_github("mdlincoln/clipr")
32
33Usage
34-----
35
36    library("clipr")
37    #> Welcome to clipr. See ?write_clip for advisories on writing to the clipboard in R.
38
39    cb <- read_clip()
40
41clipr is pipe-friendly, and will default to returning the same object
42that was passed in.
43
44    res <- write_clip(c("Text", "for", "clipboard"))
45    res
46    #> [1] "Text"      "for"       "clipboard"
47
48To capture the string that clipr writes to the clipboard, specify
49`return_new = TRUE`. Character vectors with length &gt; 1 will be
50collapsed with system-appropriate line breaks, unless otherwise
51specified
52
53
54    cb <- write_clip(c("Text", "for", "clipboard"), return_new = TRUE)
55    cb
56    #> [1] "Text\nfor\nclipboard"
57
58    cb <- write_clip(c("Text", "for", "clipboard"), breaks = ", ", return_new = TRUE)
59    cb
60    #> [1] "Text, for, clipboard"
61
62`write_clip` also tries to intelligently handle data.frames and
63matrices, rendering them with `write.table` so that they can be pasted
64into a spreadsheet like Excel.
65
66    tbl <- data.frame(a = c(1, 2, 3), b = c(4, 5, 6))
67    cb <- write_clip(tbl, return_new = TRUE)
68    cb
69    #> [1] "a\tb\n1\t4\n2\t5\n3\t6"
70
71`read_clip_tbl` will try to parse clipboard contents from spreadsheets
72into data frames directly.
73
74Developing with clipr
75---------------------
76
77See the “Developing with clipr” vignette included with this package for
78advisories on writing code that calls clipr functions.
79
80Nice uses of clipr
81------------------
82
83(a non-comprehensive list)
84
851.  [reprex](https://github.com/tidyverse/reprex) by
86    [@jennybc](https://github.com/jennybc) takes R code on the clipboard
87    and renders a reproducible example from it, ready to then paste on
88    to GitHub, Stack Overflow, or the like.
892.  [datapasta](https://github.com/milesmcbain/datapasta) by
90    [@milesmcbain](https://github.com/milesmcbain) eases the copying and
91    pasting of R objects in and out of different sources (Excel, Google
92    Sheets).
93
94------------------------------------------------------------------------
95
96[Matthew Lincoln](https://matthewlincoln.net)
97