cbapply: Apply function to contents of clipboard

Description Usage Arguments Examples

View source: R/fingerknit.R

Description

Read in clipboard contents as lines, apply a function on them, and write results back to the clipboard

Usage

1
cbapply(FUN, ..., collapse = FALSE, write = TRUE, eval = FALSE)

Arguments

FUN

function to be applied

...

optional arguments to FUN

collapse

collapse the lines into a single string separated by newlines

write

write the results back to the clipboard

eval

parse and evaluate the results

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## Not run: 
# Copy to clipboard
a <- 10
b <- 20
s <- a + b
s
# end

# Run
ev <- cbapply(FUN=function(x) paste(x, "+ 2"), eval=TRUE)
ev; a; b; s

# Clipboard contents changed to
a <- 10 + 2
b <- 20 + 2
s <- a + b + 2
s + 2
# end

# Copy to clipboard
One Two
Three
# end

# Run
cbapply(FUN=toupper, write=FALSE)

# Clipboard contents unchanged
One Two
Three
# end

## End(Not run)

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.