The title says it all: 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?
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)