blanc space not recognized

Open
#4,587 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Reproduce the report with data.table's fread() and compare unique() output against read.csv() using values with trailing spaces in FAUNISTIC_CATEGORY. Start at the fread import path and determine whether the differing levels are intentional or a parsing bug. Done means the behavior is clarified or corrected and the reported trailing-space case is covered by a regression test.

Written by the indexing model from the issue text.

Description

fread

Hi,
I'm working with a file in which some codes for FAUNISTIC_CATEGORY have a blank space at the end (actually are wrong).
Running unique() to verify number of levels, if data were imported using datatable I got:

library(data.table)
l <- fread("xx.csv",stringsAsFactors = TRUE)
unique(l$FAUNISTIC_CATEGORY)
[1] Ae Ao B C Bst
Levels: Ae Ao B Bst C

while using the "classic" readtable I got the right ones:

l <- read.csv("xx.csv")
unique(l$FAUNISTIC_CATEGORY)
[1] Ae Ao B C Bst Ae Ao C B
Levels: Ae Ae Ao Ao B B Bst C C

Data.table ver 1.12.8

R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

Could you help me?

Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.