I have my data open in another application (e.g. a spreadsheet, like Excel, or a text editor). If I copy that data to my operating system clipboard, how can I read it into R as a data.frame?
The Clipboard task pane holds many of the last images and text you copied or cut. Note: You can still do simple cut, copy, and paste the way you're used to, either by using the buttons on the ribbon or the keyboard shortcuts CTRL+X (Cut), CTRL+C (Copy), or CTRL+V (Paste).
To copy a file in R, use the file. copy() method. The file. copy() function works in the same way as a file.
Assuming you have data in the Windows clipboard (for example, copied data from Excel), to put that data into a variable named copdat
in R use:
copdat <- read.delim("clipboard")
If you want to copy data from an R variable named rdat
into the Windows clipboard (for example, to copy into Excel) use:
write.table(rdat, "clipboard", sep="\t", row.names=FALSE, col.names=FALSE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With