Importing data from MYSQL but emojis not visible

Hello Everyone. I have a dataset where I am analyzing social media comments for my thesis. In MySQL database, the comments contain emojis (collation: utf8mb4), but when I am importing it in Rstudio, only a question mark is showing in place of the emojis.

Any idea how to solve this?
R:
Capture

Check that the script from which you are running the command is set for UTF-8 encoding. In RStudio, use File | Reopen with Encoding | UTF-8

I tried that.... but still nothing ...

Dear Community. I somehow found a solution, I hope this might help someone out there.
Before retrieving data from database, run the following:
rs <- dbSendQuery(mydb, 'set character set "utf8mb4"')
then, after successfully importing dataset, run:
Encoding(clevel$comment) <- "UTF-8"
where clevel is my dataframe and comment is the comment text column.
Capture

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.