In regard to the code below, if a vector contains a mix of strings & numbers , is the vector considered as having all string values.
as.numeric(stringr::str_replace(rooms, ‘10 or more’, ‘10’))
In regard to the code below, if a vector contains a mix of strings & numbers , is the vector considered as having all string values.
as.numeric(stringr::str_replace(rooms, ‘10 or more’, ‘10’))
Hello @sharathnandalike
This is a very good question.
No. If you try to add number (without quotes) like in this syntax stringr::str_replace(rooms, '10 or more', 10)
, you will get this kind of error:
Error : `replacement` must be a character vector
FYI:
This is not possible in R. A vector is supposed to contain values of the same type.
Best,
John.