We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register 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.RScriptRuntimeExceptionI 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_tweets1Thank you.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |