How to read in numbers with a comma as decimal separator?
When you check ?read.table
you will probably find all the answer that you need.
There are two issues with (continental) European csv files:
- What does the
c
in csv stand for? For standard csv this is a,
, for European csv this is a;
sep
is the corresponding argument inread.table
- What is the character for the decimal point? For standard csv this is a
.
, for European csv this is a,
dec
is the corresponding argument inread.table
To read standard csv use read.csv
, to read European csv use read.csv2
. These two functions are just wrappers to read.table
that set the appropriate arguments.
If your file does not follow either of these standards set the arguments manually.
From ?read.table
:
dec the character used in the file for decimal points.
And yes, you can use that for read.csv
as well. (to me: no stupid, you cannot!)
Alternatively, you can also use
read.csv2
which assumes a "," decimal separator and a ";" for column separators.