From the result you have observed, I will assume you are using a Portuguese version of Windows Excel. Usually, when we save a Windows Excel spreadsheet in CSV, it is saved with ;
as a separator. This happens mainly in Brazilian (some European) versions of Excel, because our decimal separator is the comma, and not the point, as it is in the United States.
In the R this is already, in a way, anticipated by the function read.csv2
(see here), that has the configuration of headers, decimals and separators that Windows Excel uses as default. See in the function setting, making ?read.csv
read.csv(file, header = TRUE, sep = ",", quote = "\"",
dec = ".", fill = TRUE, comment.char = "", ...)
read.csv2(file, header = TRUE, sep = ";", quote = "\"",
dec = ",", fill = TRUE, comment.char = "", ...)
In addition to this possible solution, as Anthony said, there are packages that make it easy to read files directly from Excel, such as packages xlsx
and gdata
. Behold here and here.
Hello Adriana, post some lines of your csv file, you will probably need to set a different tab (and maybe also the character that involves Strings). Anyway, did you know that there are packages that allow you to read xlsx files directly? Take a look at the package xlsx cran.
– Anthony Accioly
Thank you Anthony, I managed to install the xlsx package, very good tip.
– Adriana
Adriana, if any of the answers answered your question, you can accept it by clicking on the "ok" symbol on the left.
– Carlos Cinelli
This question also deals with: http://answall.com/q/19125/6036
– Daniel Falbel