Will assign the contents of the clipboard to the vector x. The companion function for writeClipboard is readClipboard. After a vector has been copied to the clipboard, the elements of the vector will be separated by newlines when pasted into a document.
If one element of a vector is a character string, all elements will be cast to strings without the need for an explicit as.character statement. The solution is to call writeClipboard( as.character(x) ), casting the object x to a character string.Īll variables in R are vectors, and elements of a vector can have differing types.
Produces the error message Error in writeClipboard(str, format) :Īrgument must be a character vector or a raw vector For example the code > x writeClipboard(x)Ĭopies the string “hello world” to the clipboard as expected. However, the argument to writeClipboard may need to be cast to a character type. R has a function writeClipboard that does what the name implies. These notes explain how to move data between R and Excel and other Windows applications via the clipboard.