Prints a vector to paste into an R script
Usage
print_c(x = read_clipboard(), sorted = TRUE, null = TRUE)Arguments
- x
A vector (defaults to reading the clipboard)
- sorted
If
TRUE(default) appliesbase::sort()tox- null
If
TRUE(default) addsNULLat the end of thebase::c()print
Details
This sorts (if set) and provides unique values for each element in
x and prints then as a call to base::c(). This can be useful for
copying data that you want to save as a vector in an R script. The
result is both called in base::cat() as well as copied to the clipboard.
Examples
print_c(1:10)
#> c(
#> 1,
#> 2,
#> 3,
#> 4,
#> 5,
#> 6,
#> 7,
#> 8,
#> 9,
#> 10,
#> NULL
#> )
print_c(letters[1:3])
#> c(
#> "a",
#> "b",
#> "c",
#> NULL
#> )
print_c(month.abb)
#> c(
#> "Apr",
#> "Aug",
#> "Dec",
#> "Feb",
#> "Jan",
#> "Jul",
#> "Jun",
#> "Mar",
#> "May",
#> "Nov",
#> "Oct",
#> "Sep",
#> NULL
#> )