Another seemingly bug in dealing with NAs
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
Research direction
Start by running the minimal fread example from the issue and compare its output with the version where quoted NA values are replaced by XX. Trace fread's handling of NA strings, quoted values, and empty fields, then verify that a regression test preserves the expected distinction between empty fields, unquoted NA, and quoted "NA".
Written by the indexing model from the issue text.
Description
Too much requirement readings... I think I did my best :)
NA seems to cause all sorts of problem...
Here is my Minimal Example.
txt = r"(
NA,"NA","",
"NA",,"",NA
"",NA,,"NA"
)"
fread(txt) # whether header=TRUE or FALSE
# V1 V2 V3 V4
# 1: NA NA NA NA
# 2: NA NA NA NA
# 3: NA NA NA NA
Here is what it should do(it is just that "NA" is changed to "XX")
txt = r"(
NA,"XX","",
"XX",,"",NA
"",NA,,"XX"
)"
fread(txt, header=FALSE)
# V1 V2 V3 V4
# 1: <NA> XX NA
# 2: XX NA <NA>
# 3: <NA> NA XX
except for one thing that V3 are all NAs... where is ""?
It doesnot matter whether or not you set na.strings = 'NA'
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=Korean_Korea.949 LC_CTYPE=Korean_Korea.949 LC_MONETARY=Korean_Korea.949
[4] LC_NUMERIC=C LC_TIME=Korean_Korea.949
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.14.2 dplyr_1.0.7
loaded via a namespace (and not attached):
[1] fansi_0.5.0 assertthat_0.2.1 utf8_1.2.2 crayon_1.4.2 R6_2.5.1
[6] DBI_1.1.1 lifecycle_1.0.1 magrittr_2.0.1 pillar_1.6.4 cli_3.1.0
[11] rlang_0.4.12 rstudioapi_0.13 vctrs_0.3.8 generics_0.1.1 ellipsis_0.3.2
[16] tools_4.1.0 glue_1.4.2 purrr_0.3.4 compiler_4.1.0 pkgconfig_2.0.3
[21] tidyselect_1.1.1 tibble_3.1.5
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one) Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·