quanteda / readtext

an R package for reading text files
https://readtext.quanteda.io
120 stars 28 forks source link

text_field can be given a vector and does not raise a warning #150

Closed kbenoit closed 5 years ago

kbenoit commented 5 years ago

The last two only take the first element of the character vector to be used as the (single) text_field. We should raise a warning that only the first element is used.

library("readtext")

readtext("/Users/kbenoit/Dropbox/GitHub/quanteda/readtext/tests/data/csv/test3.csv", text_field = "colour")
## readtext object consisting of 2 documents and 2 docvars.
## # Description: data.frame [2 × 4]
##   doc_id      text            text.1    number
##   <chr>       <chr>           <chr>      <int>
## 1 test3.csv.1 "\"orange\"..." The quick      0
## 2 test3.csv.2 "\"blue\"..."   brown fox     NA
readtext("/Users/kbenoit/Dropbox/GitHub/quanteda/readtext/tests/data/csv/test3.csv", text_field = "text")
## readtext object consisting of 2 documents and 2 docvars.
## # Description: data.frame [2 × 4]
##   doc_id      text               colour number
##   <chr>       <chr>              <chr>   <int>
## 1 test3.csv.1 "\"The quick\"..." orange      0
## 2 test3.csv.2 "\"brown fox\"..." blue       NA
readtext("/Users/kbenoit/Dropbox/GitHub/quanteda/readtext/tests/data/csv/test3.csv", text_field = c("text", "colour"))
## readtext object consisting of 2 documents and 2 docvars.
## # Description: data.frame [2 × 4]
##   doc_id      text               colour number
##   <chr>       <chr>              <chr>   <int>
## 1 test3.csv.1 "\"The quick\"..." orange      0
## 2 test3.csv.2 "\"brown fox\"..." blue       NA
readtext("/Users/kbenoit/Dropbox/GitHub/quanteda/readtext/tests/data/csv/test3.csv", text_field = c("colour", "text"))
## readtext object consisting of 2 documents and 2 docvars.
## # Description: data.frame [2 × 4]
##   doc_id      text            text.1    number
##   <chr>       <chr>           <chr>      <int>
## 1 test3.csv.1 "\"orange\"..." The quick      0
## 2 test3.csv.2 "\"blue\"..."   brown fox     NA
amatsuo commented 5 years ago

resolved by PR #156