New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_delim converts "." to "0" #297

Closed
katwre opened this Issue Oct 22, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@katwre

katwre commented Oct 22, 2015

The problem is that "." is parsed as a number like ".0", and as a result it returns "0". That's why adding locale = locale(decimal_mark = ",", grouping_mark = "_") to read_delim helps. Here is an example:

> file = "chr1\t1\t10\t.\t15\t20\nchr1\t5\t15\t.\t20\t25"
> read_delim(file, delim="\t", col_names=F)
    X1 X2 X3 X4 X5 X6
1 chr1  1 10  0 15 20
2 chr1  5 15  0 20 25

Apart of that it converts "+" and "-" to NA or "0" and that I just do not understand, e.g:

> file = "chr1\t1\t10\t+\t15\t20\nchr1\t5\t15\t-\t20\t25"
> read_delim(file, delim="\t", col_names=F)
Warning: 1 parsing failure.
row col expected actual
  1  X4 a number       
    X1 X2 X3 X4 X5 X6
1 chr1  1 10 NA 15 20
2 chr1  5 15  0 20 25
@hadley

This comment has been minimized.

Member

hadley commented Jun 2, 2016

Minimal reprex:

collector_guess("-")
collector_guess(".")
@jimhester

This comment has been minimized.

Member

jimhester commented Jun 7, 2016

@hadley Just to be clear, we want the following

collector_guess("-")
#> character
collector_guess(".")
#> character
@hadley

This comment has been minimized.

Member

hadley commented Jun 7, 2016

Right.

@jimhester jimhester self-assigned this Jun 7, 2016

@jimhester jimhester added in progress and removed ready labels Jun 7, 2016

@hadley hadley closed this in #418 Jun 7, 2016

@hadley hadley removed the in progress label Jun 7, 2016

@lock lock bot locked and limited conversation to collaborators Sep 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.