Lets say I have a file on desktop called called ‘test.csv’. I discovered by accident that if I drag ‘test.csv’ to an R file, this code is pasted into the R file:

read.csv(file = "../../../../Desktop/test.csv", header = TRUE, stringsAsFactors = FALSE)

But if the file is a .xls file, only this get pasted into the R file:

/Users/rossahmed/Desktop/test.xls

How can I add a command that, when I drag a .xls file into an R file, this get pasted in:

read.xls("/Users/rossahmed/Desktop/test.xls")