hadley / r4ds

R for data science: a book
http://r4ds.hadley.nz
Other
4.51k stars 4.19k forks source link

Section 14.6.1 second code chunk throws an error #1671

Open stephenbalogun opened 2 months ago

stephenbalogun commented 2 months ago

The code chunk below from the book chapter is no longer reproducible using R version 4.4.0 and {readr} 2.1.5

x1 <- "text\nEl Ni\xf1o was particularly bad this year"
read_csv(x1)$text
#> [1] "El Ni\xf1o was particularly bad this year"

The chunk now throws an error as shown below:

x1 <- "text\nEl Ni\xf1o was particularly bad this year"
readr::read_csv(x1)$text
#> Warning in grepl("\n", path): unable to translate 'text
#> El Ni<f1>o was particularly bad this year' to a wide string
#> Warning in grepl("\n", path): input string 1 is invalid
#> Warning in grepl("^((http|ftp)s?|sftp)://", path): unable to translate 'text
#> El Ni<f1>o was particularly bad this year' to a wide string
#> Warning in grepl("^((http|ftp)s?|sftp)://", path): input string 1 is invalid
#> Warning in regexpr(regex, path, perl = TRUE): input string 1 is invalid UTF-8
#> Error in file.exists(path): file name conversion problem -- name too long?

Created on 2024-06-18 with reprex v2.1.0

davidrsch commented 2 months ago

This is related to issues #1478 and #1599 both related with tidyverse/readr#1521 . The changes suggested in the last mentioned issue hasn't yet been applied.