Importing Excel matrix to R.

J

jk90029

Guest
#1
For an easy example, assume that Excel data ""text.xls"" in Excel 2003 (old version) version

1 3
2 5

located at the root directory c:\\ .

If we want to import the matrix to an R data matrix with same size in R data directory, I used the command

read.csv(file="c:\\test. xls", header=FALSE)

However, it does not work at all. Something is wrong?

Thanks in advance.

-J
 

Dason

Ambassador to the humans
#4
Did you resave the excel file as a csv or just rename the file to test.csv? Because the first should work whereas the second one wouldn't do anything other than change the name.
 
J

jk90029

Guest
#5
Did you resave the excel file as a csv or just rename the file to test.csv? Because the first should work whereas the second one wouldn't do anything other than change the name.
Thanks Dason.

Of course,

1) read.csv(file="c:\\test. xls", header=FALSE)

2) read.csv(file="c:\\test. csv", header=FALSE)

are used separately but STILL first one does NOT work.
 
J

jk90029

Guest
#6
Dason / Probably my mistake in directory.

Everything is fine NOW with no problem in the command.

Thanks again.
 

Dason

Ambassador to the humans
#7
1) read.csv(file="c:\\test. xls", header=FALSE)

2) read.csv(file="c:\\test. csv", header=FALSE)

are used separately but STILL first one does NOT work.
The first one never should work. The second one should work if the file really is a csv (not just a .xls renamed to filename.csv).

Note: I moved the rest of the thread to it's own thread because it wasn't related to the original topic. http://www.talkstats.com/showthread.php/18109-Move-S-functions-to-R
 
Last edited: