There is a function to convert English numbers(one, two) to numeral(1, 2):
library(remotes)
remotes::install_github("fsingletonthorn/words_to_numbers")
library(wordstonumbers)
The input and output are:
input: words_to_numbers("one and threefold and five tennis")
output: "1 and threefold and 5 tennis"
It works well at once, my question is how to do the same operation for one column with over 1000 observations within a dataframe.
For dataframe called"data", the column needs to be convert is data$texts, I tried:
data <- within(data, {
texts_new <- words_to_numbers(texts)
})
Got:
The argument which was passed to words_to_numbers is not a length 1 character element, only the first element has been used here. Consider using the apply or purrr::map functions to assess multiple elements at once.