简体   繁体   中英

Error in reading element of a vector in R

I would like to convert some numbers to words (so 5 becomes "five" etc). I am using english library to create a vector of integers that have been transformed into words. However, when I try to access some elements of my vector (elements after 100), I receive the following error:

Error in UK && (d <- makeNumber(dvec)) > 0: invalid 'x' type in 'x && y'

Here is my code:

library(english)
words <- as.english(c(1:1000))
words[999]

The aim is to access any element of a vector words .

The english class can be converted to character

as.character(words)[999]
#[1] "nine hundred ninety-nine"

The issue starts with 3 digit number onwards

words[100]  

Error in UK && (d <- makeNumber(dvec)) > 0: invalid 'x' type in 'x && y'


Checked for methods with [

grep('english', methods(`[`), value = TRUE)
#[1] "[.english"

So, there is an existing method to subset, but may be it is a bug

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM