R. Converting a vector of type character, into a string

R. Converting a vector of type character, into a string

a string (as defined in the sense of the NLP package) is not the same as a base-R character.

library(NLP)
xchar <- abc
xstring <- as.String(abc)

> xchar
[1] abc
> xstring
abc

From this you can already see one of the differences of NLP stings and base R characters, namely the printing properties.
Also:

> is.character(xstring)
[1] TRUE
> is.String(xstring)
[1] TRUE
> is.character(xchar)
[1] TRUE
> is.String(xchar)
[1] FALSE

So if you want a String object you should use as.String instead of as.character

R. Converting a vector of type character, into a string

Leave a Reply

Your email address will not be published. Required fields are marked *