[R] Error in using tokens script

PIKAL Petr petr@p|k@| @end|ng |rom prechez@@cz
Wed May 29 09:31:31 CEST 2019


Most probably SMSSpamCollection$Message is not character, corpus or tokens object (which error message politely suggests).

You need to change it to be correct mode

functions ?str, ?mode, ?typeof

to see your objects.

And maybe also R intro chapter about objects and its differences.


> -----Original Message-----
> From: R-help <r-help-bounces using r-project.org> On Behalf Of Jianjun Wang
> Sent: Tuesday, May 28, 2019 6:51 PM
> To: r-help using R-project.org
> Subject: [R] Error in using tokens script
> Hi, Colleagues.
> As shown at the bottom, I was able to obtain information from a column
> (named "Message") of a text data (named "SMSSpamCollection" (i.e.,
> SMSSpamCollection$Message[44]).  But when I ran SMSSpamCollection.token
> <-tokens(SMSSpamCollection$Message, what="word",
> +                                  remove_url = TRUE,
> +                                  remove_numbers= TRUE, remove_punct= TRUE,
> +                                  remove_symbols= TRUE, remove_hyphens=
> + TRUE)
> The feedback was
> Error in tokens.default(SMSSpamCollection$Message, what = "word",
> remove_url = TRUE,  :
>   tokens() only works on character, corpus, tokens objects.
> I would appreciate some guidance to fix the error message!
> Thank you.
> JJ
> > SMSSpamCollection$Message[44]
> [1] Great! I hope you like your man well endowed. I am  <#>  inches...
> 3026 Levels: 'An Amazing Quote'' - Sometimes in life its difficult to decide
> whats wrong!! a lie that brings a smile or the truth that brings a tear.... ...
> [[alternative HTML version deleted]]
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about processing and protection of business partner’s personal data are available on website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/

More information about the R-help mailing list