March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello All,
I am trying to ger the twitter data using R script in power bi desktop.
Here is the script that i have used to get the twitter data.
library(twitteR) source("authenticate.R") tweets <- searchTwitter("Virat",n = 100,lang = "en") tweetsdf <- twListToDF(tweets)
Details: "Unable to translate bytes [ED][A0] at index 127 from specified code page to Unicode."
It is running fine and am able to get the tweets in R studio, but not in Power Bi R script.
Please suggest me.
Solved! Go to Solution.
I have solved this issue by using stringi package.
here is the script that i have used.
library(twitteR)
library(stringi)
tweets <- searchTwitter(search_term, number_of_tweets )
#convert received data to something PowerBi understands
df_tweets <- twListToDF(tweets)
#column clean
df_tweets$text <- stri_encode(df_tweets$text, "", "UTF-8")
It cleans the column which are not understandable.
Could you post the completed code? I did download the twitteR and OATH package, however not yet to run your R script.
I have solved this issue by using stringi package.
here is the script that i have used.
library(twitteR)
library(stringi)
tweets <- searchTwitter(search_term, number_of_tweets )
#convert received data to something PowerBi understands
df_tweets <- twListToDF(tweets)
#column clean
df_tweets$text <- stri_encode(df_tweets$text, "", "UTF-8")
It cleans the column which are not understandable.
Hi @Anonymous ,
I am using the same R library to extract tweets in powerBI . My R script is working fine when the search_term is hardcoded. But when I am trying to create an invoked function to pass the search_term as a parameter it gives the following error.
An error occurred in the ‘’ query. DataSource.Error: ADO.NET: R script error. During startup - Warning message: In setJsonDatabasePath(system.file("extdata/capabilities.json", : bytecode version mismatch; using eval Error: unexpected symbol in: "rScriptWrapper_options = getOption('save.image.defaults') save(list = rScriptWrapper_dataFrames, file = "globalEnv.rdata" Execution halted Details: DataSourceKind=R DataSourcePath=R Message=R script error. During startup - Warning message: In setJsonDatabasePath(system.file("extdata/capabilities.json", : bytecode version mismatch; using eval Error: unexpected symbol in: "rScriptWrapper_options = getOption('save.image.defaults') save(list = rScriptWrapper_dataFrames, file = "globalEnv.rdata" Execution halted ErrorCode=-2147467259 ExceptionType=Microsoft.PowerBI.Scripting.R.Exceptions.RScriptRuntimeException
I am very new to PowerBI and hence trying a lot to solve this issue. I really appreciate any suggestion regarding this. I am also attaching the R script for creating the invoked function.
(Name as text) as table=> let Source = R.Execute(" #(lf) library(twitteR) #(lf) library(stringi) #(lf) consumer_key <- ""8R96HfpMmwog1w4V0f6HrfwS9"" #(lf) consumer_secret <- ""Smun1VSNdn30P5HfvAJ4AR8XSmqOevkGCvwQ2RJpXrHptRTEui"" #(lf) access_token <- ""1306483171-2I5rsnK7AvYStXEja7lDu9AAI7ftuv6CvcbhhW0"" #(lf) access_secret <- ""SlsagLzQfoaE0VzocM6ycFLqSk0PtImwekwENZt339yej"" #(lf) setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret) #(lf) str1 <- ""#"" #(lf) str2 <- ""&Name&"" (passing parameter here) #(lf) search_term <- paste(str1,str2,sep="") #(lf) number_of_tweets <- 100 #(lf) language <-'en' #(lf) tweets <- searchTwitter(search_term, number_of_tweets,language) #(lf) df_tweets <- twListToDF(tweets) #(lf) df_tweets <- df_tweets[,c('text','favorited','favoriteCount','created','retweetCount', 'isRetweet','retweeted')] #(lf) df_tweets$text <- stri_encode(df_tweets$text, '', 'UTF-8')"), df_tweets1 = Source{[Name="df_tweets"]}[Value] in df_tweets1
Thank you.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
8 | |
3 | |
2 | |
1 | |
1 |
User | Count |
---|---|
6 | |
3 | |
2 | |
2 | |
2 |