Skip to content

R data.table::fwrite prints huge numebrs as Xe+0X #60

Open
renewiegandt opened this issue Jan 11, 2019 · 2 comments · Fixed by #63
Open

R data.table::fwrite prints huge numebrs as Xe+0X #60

renewiegandt opened this issue Jan 11, 2019 · 2 comments · Fixed by #63
Labels
bug Something isn't working

Comments

@renewiegandt
Copy link
Collaborator

renewiegandt commented Jan 11, 2019

reduced.bed
Line 43957
chr2 172999990 1.73e+08 f_108017.0 0.551591 . 32 42 0

To fix this convert the values to integer before writing the data.table!

@renewiegandt renewiegandt changed the title R data.table::fwrite prints huge numebrs as R data.table::fwrite prints huge numebrs as Xe+0X Jan 11, 2019
@renewiegandt renewiegandt added the bug Something isn't working label Jan 11, 2019
@HendrikSchultheis
Copy link
Collaborator

Looking into this bug I found this issue. So the problem is that fwrite cannot disable the scientific notation at this moment (e.g. 1e+10). Luckily they provide a workaround by casting columns to integer64 (needs bit64 package).

While this bug so far only occurred in the reduce_sequence.R script it is most likely that this will happen in all of our R scripts. I am currently testing a code line which should fix this in all scripts. I will provide it ASAP.

@HendrikSchultheis
Copy link
Collaborator

  # cast start and end column to integer64 to prevent scientific notation e.g. 1e+10
  # start and end are assumed to be at position 2 and 3
  table[, c(2, 3) := lapply(.SD, bit64::as.integer64), .SDcols = c(2, 3)]

Sign in to join this conversation on GitHub.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants