0

I have a .csv file where columns 2 and beyond are dollar amounts such as $1004.23, ($1482.40), $2423.94, etc. Similar to the example below:

id   desc    price
0    apple   $1.00
1    banana  ($2.25)
2    grapes  $1.97

When I bring in this file using the below command, all of my numbers get rounded so $1.00 becomes $1 and ($2.25) becomes ($2).

df <- read.csv(file.path(path = path, file = "filename"), header=TRUE, sep=",", stringsAsFactors=FALSE, dec=".")

I've tried it without the dec="." option to no avail.

rafa.pereira
  • 10,729
  • 4
  • 59
  • 88
werkTJwerk
  • 57
  • 5
  • 1
    Interesting It does not round off for me. Possible that it is not truncating but when you printing dataframe it is resulting truncation. try `print(df, digits=5)` – user5249203 Jun 06 '16 at 18:57
  • This is more related to your Q. http://stackoverflow.com/questions/7337824/read-csv-file-in-r-with-currency-column-as-numeric – user5249203 Jun 06 '16 at 19:13
  • 2
    This isn't reproducible as written. Can you `dput` an excerpt from the file and show the rounded output? – effel Jun 06 '16 at 19:15

0 Answers0