Giter Club home page Giter Club logo

clipr's Introduction

clipr

CRAN status. Downloads, grand total Travis-CI Build Status AppVeyor Build Status Coverage Status

Simple utility functions to read and write from the system clipboards of Windows, OS X, and Unix-like systems (which require either xclip or xsel.)

Installation

Install from CRAN

install.packages("clipr")

Or try the development version

devtools::install_github("mdlincoln/clipr")

Usage

library("clipr")
#> Welcome to clipr. See ?write_clip for advisories on writing to the clipboard in R.

cb <- read_clip()

clipr is pipe-friendly, and will default to returning the same object that was passed in.

res <- write_clip(c("Text", "for", "clipboard"))
res
#> [1] "Text"      "for"       "clipboard"

To capture the string that clipr writes to the clipboard, specify return_new = TRUE. Character vectors with length > 1 will be collapsed with system-appropriate line breaks, unless otherwise specified

cb <- write_clip(c("Text", "for", "clipboard"), return_new = TRUE)
cb
#> [1] "Text\nfor\nclipboard"

cb <- write_clip(c("Text", "for", "clipboard"), breaks = ", ", return_new = TRUE)
cb
#> [1] "Text, for, clipboard"

write_clip also tries to intelligently handle data.frames and matrices, rendering them with write.table so that they can be pasted into a spreadsheet like Excel.

tbl <- data.frame(a = c(1, 2, 3), b = c(4, 5, 6))
cb <- write_clip(tbl, return_new = TRUE)
cb
#> [1] "a\tb\n1\t4\n2\t5\n3\t6"

read_clip_tbl will try to parse clipboard contents from spreadsheets into data frames directly.

Developing with clipr

See the “Developing with clipr” vignette included with this package for advisories on writing code that calls clipr functions.

Nice uses of clipr

(a non-comprehensive list)

  1. reprex by @jennybc takes R code on the clipboard and renders a reproducible example from it, ready to then paste on to GitHub, Stack Overflow, or the like.
  2. datapasta by @milesmcbain eases the copying and pasting of R objects in and out of different sources (Excel, Google Sheets).

Matthew Lincoln

clipr's People

Contributors

cderv avatar jennybc avatar krivit avatar lmmx avatar mdlincoln avatar milesmcbain avatar qulogic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.