0

I'm unable to import my data, and the R console reports object not found. Any suggestions?


    install.packages("tidyverse")
    library(tidyverse)

    y <- read_tsv("assignment_data.tsv")

  x <- 1

Above the error that I receive:

enter image description here

However, the variable x is available in the global environment.

James Z
  • 12,209
  • 10
  • 24
  • 44
github292929
  • 185
  • 7
  • (1) please paste your console output as text rather than as an image; (2) this seems fairly straightforward -- your file wasn't read because it has a character in it that is illegal in your current locale. It's hard to say more without more information. If you can post a link to the file people might help you track down and solve the problem. (3) Please don't put "urgent" in your title -- it may be urgent for you, but it doesn't necessarily do anything to encourage people to help you ... – Ben Bolker Mar 20 '22 at 18:57
  • Thanks for replying. What do you mean by character that is illegal? Could it be my file path? – github292929 Mar 20 '22 at 18:58
  • No, it'll be a character in the file itself. – Ben Bolker Mar 20 '22 at 18:59
  • Please dont! I'm really quite desperate but could it be the _ in the file? – github292929 Mar 20 '22 at 19:02
  • Please read the linked duplicate questions (there are two sets, https://stackoverflow.com/questions/4993837/r-invalid-multibyte-string and https://stackoverflow.com/questions/14363085/invalid-multibyte-string-in-read-csv ). Some of the answers there are specific to `read.csv` rather than `readr::read_csv`, but quite a few are general. If after carefully reading those answers you decide that your question is different/still unresolved, then feel free to edit your question to indicate *how* it is different and we can re-open it. – Ben Bolker Mar 20 '22 at 19:50
  • From what I can see the "_" character you've posted is a regular ASCII underscore, so shouldn't be a problem, but there are variant characters such as Unicode 0332 that look almost identical and could be causing trouble: https://unicode-search.net/unicode-namesearch.pl?term=UNDERSCORE ... please **read the linked questions/answers** and come back with any remaining questions ... – Ben Bolker Mar 20 '22 at 19:52
  • PS this is probably the most useful answer from that stack: https://stackoverflow.com/a/23227869/190277 , i.e. define that function, then `r <- readLines("assignment_data.tsv"); lapply(r, find_offending_character)` – Ben Bolker Mar 20 '22 at 20:08

0 Answers0