Sarah May Muholland
Sarah May Muholland

Reputation: 187

Using R to choose files from excel

I've been trying to import excel files into R....using the choose file function

mydata=read.csv(file.choose())

or

myFile <- file.choose()
myData  <- read.table(myFile,header=TRUE)

but I get the same error

Error in file.choose() : file choice cancelled

I'm using R version 2.15.3

How do I fix this? Or is there another way to do this?

Upvotes: 3

Views: 2114

Answers (1)

Brian Diggs
Brian Diggs

Reputation: 58845

I can get the error you indicate

Error in file.choose() : file choice cancelled

only by hitting Cancel on the file dialog box. If I select a file and hit Open, it works as intended (R-3.0.1).

Also, "Excel file" is not well defined. Do you mean a .csv file saved from Excel? An .xls file? An .xlsx file? Each of these is a different format and needs a different function to read/import them.

Upvotes: 1

Related Questions