Skip to content
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

Error in read_tokens_ in 1.4.0 for a file that reads correctly in 1.3.1 #1140

Closed
martinmodrak opened this issue Oct 23, 2020 · 3 comments
Closed
Labels
reprex needs a minimal reproducible example

Comments

@martinmodrak
Copy link

I am getting a cryptic message when reading a .csv file with readr 1.4.0, providing the col_types argument:

Error in read_tokens_(data, tokenizer, col_specs, col_names, locale_, : Invalid input type, expected 'character' actual 'double'

The same file reads correctly:

  • Without providing the col_types argument
  • In readr 1.3.1 with the exact same call (including the col_types argument)

I cannot share the file as it contains patient data and don't have a better reprex, but I am sharing it here in hope others who encounter the error will find this and learn that they may work around it by installing 1.3.1 and hopefully they will be able to share their files. I understand that it is hard to take action on the issue without a reprex. Sorry if this is not appropriate and thanks for all the hard work on the package.

@jimhester
Copy link
Collaborator

jimhester commented Oct 23, 2020

You can use fake data to reproduce it, what you are passing as the col_types argument?

@jimhester jimhester added the reprex needs a minimal reproducible example label Oct 23, 2020
@sleyn
Copy link

sleyn commented Mar 3, 2021

Hello!

I had an issue with the same error.
The error was caused by col_factor(levels = c(1, 2, 3, 4)). It was fine with the previous version of readr (don't remember what I had before). With readr 1.4.0 I've got:
Error in read_tokens_(data, tokenizer, col_specs, col_names, locale_, : Invalid input type, expected 'character' actual 'double'
The error was solved with making the levels vector as a character vector col_factor(levels = c('1', '2', '3', '4')).

@jimhester
Copy link
Collaborator

Thanks @sleyn.

readr now throws a more informative error in this case. However passing non-character vectors as levels is still an error and needs to be fixed in your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reprex needs a minimal reproducible example
Projects
None yet
Development

No branches or pull requests

3 participants