to_vector_code: Convert vector to R code for a vector

Description Usage Arguments Value Examples

View source: R/functions_vector_code.R

Description

This function converts the clipboard (or indeed any character vector) into the code for an R vector. This can be useful if there it is necessary to “hard-code” vectors.

It treats entirely numeric clipboards — picked up by clipboard_is_numeric — slightly differently to supposed “character” clipboards.

Usage

1
to_vector_code(x = clipr::read_clip())

Arguments

x

A character vector (defaults to the clipboard).

Value

We show the output by way of the following examples that assume x is the clipboard.

Numeric: suppose we copy the following into the clipboard...

1

2

3

Then the function will output c(1,2,3).

Character: suppose we copy the following into the clipboard...

Apple

Orange

Banana

Then the function will output c("Apple","Orange","Banana").

Examples

1
2
3
4
5
6
## Not run: 
 # numeric example
 clipboard_to_R_vector(c("1","2","3"))
 # character example
 clipboard_to_R_vector(c("Apple","Orange","Banana")) 
## End(Not run)

t-gummer/RADins documentation built on Sept. 14, 2020, 7:58 p.m.