'Encoding the string as UTF8 by using the enc2utf8

I'm using R to attempt to do a sentiment analysis from public Reddit interactions about diabetes.

This is my sessioninfo() R version 4.0.2 (2020-06-22) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Catalina 10.15.7

I successfully extracted the dataset using the RedditExtractor library. However, when I run the "sentiment" command from the SentimentAnalysis package, I get the following error message:

Error in FUN(content(x), ...): invalid multibyte string 1

I know the problem is not my code and the error has something to do with "characters not recognized by the character encoding format."

How can I use the function enc2utf8 to encode the string as UTF8?

Please check the code below:

library("RedditExtractoR") Diabetes_Dataset <- get_reddit(subreddit = "diabetes",page_threshold = 5, sort_by= "comments") library("SentimentAnalysis") sentiment <- analyzeSentiment(Diabetes_Dataset$comment)

I tried the following but got the same error:

enc2utf8(sentiment <- analyzeSentiment(Diabetes_Dataset$comment))

Error in FUN(content(x), ...) : invalid multibyte string 1

I appreciate any help anyone can provide. Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source