The manual of count_fields {readr} decribe the file parameter as following:
To be recognised as literal data, the input must be either wrapped with I(), be a string containing at least one new line, or be a vector containing at least one string with a new line.
However, wrapping the string with I() doesn't seem to have any effekt. If file is a single string it is interpreted as a file name even when wrapped with I() instead of literal data.
data <- c('"foo","bar","baz"')
count_fields(I(data), tokenizer = tokenizer_csv())
Error: '"foo","bar","baz"' does not exist in current working directory
Expected result: 3
Workaround: temporarly attach a new line.
data <- c('"foo","bar","baz"')
count_fields(paste0(data, "\n"), tokenizer = tokenizer_csv())
readr version: 2.1.5