cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tn_Gartn
Frequent Visitor

Error in running an R script using sentimentr library in PowerBI

sentimentr_qvr <- read.csv("C:/data/CES.csv")

sentimentr_qvr_sentence <-get_sentences(sentimentr_qvr)
library(sentimentr)
library(lubridate)
library(ggplot2)
library(dplyr)
library(readr)
library(stringr)
library(tidytext)
library(dplyr)
library(sentimentr)
sentimentr_qvr_sentence <-get_sentences(sentimentr_qvr)
library(sentimentr)
average_sent_score <- sentiment_by(sentimentr_qvr_sentence, by = NULL)

 

Above code runs fine in R studio but its throwing error when i run through PowerBI. your help is very much appreciated!

Error DetailError Detail

8 REPLIES 8
dedelman_clng
Super User
Super User

Check to see if that library/package is supported by PowerBI at this time.  See this link for documentation:

 

https://docs.microsoft.com/en-us/power-bi/service-r-packages-support

 




Proud to be a Super User!




Anonymous
Not applicable

Hi @dedelman_clng ,

 

I am also trying to use "sentimentr" library in My powerBI dataset. But having the same "DataFormat.Error: ENVSXP" for the same script. My code also works fine in RStudio. I am very new to PowerBI. I really appreciate any suggestion regarding this.

# 'dataset' holds the input data for this script
#dataset has only one 'Text' column
library(dplyr)
library(sentimentr)


df_final_tweets <- data.frame (
  Tweet_Text = c(dataset$Text),
  stringsAsFactors = FALSE
)

senti_text <- get_sentences(df_final_tweets)
Sentiment = sentiment_by(senti_text,by = NULL)

dataset_with_Sentiment_score <- data.frame (
  Tweet_TEXT = c(df_final_tweets$Tweet_Text),
  Senti_Score = round(Sentiment$ave_sentiment , 2 ),
  stringsAsFactors = FALSE
)

Note: According to the Most Recent PowerBI Documentation "sentimentr" package is supported by PowerBI at this time. 

 

Thanks in advance.

 

Please make sure you have the latest version of PowerBI and show us the entirety of the "R script editor" window that you are using.




Proud to be a Super User!




Anonymous
Not applicable

Hi @dedelman_clng ,

 

Thanks for replying. I am using the latest(September 2019)  version of PowerBI. PBI_Version.JPG

 

also, I am attaching some screenshot of the results I got in RStudio.

Rstudio.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards,

Nahar

 

Unless I'm mistaken, the output of an R Script in PowerBI needs to be a plot of some kind (ggplot, etc). You are just creating a data frame and attempting to output it.

 

Here is the documentation for R in PowerBI:

https://docs.microsoft.com/en-us/power-bi/visuals/service-r-visuals




Proud to be a Super User!




Anonymous
Not applicable

@dedelman_clng ,

 

I just need the dataframe with the score and output it to the PowerBI from the R script I added. I don't want to create any visualization in R , for that part I think powerBI is a much better tool . 

 

I have done this (importing a dataframe as an output) in powerBI with other R packages. But seems like the problem is only for using this 'sentimentr' package. 

By any chance is it still not supported fully by powerBI although the official documentation says so. 

What you are describing is using R as a data source, as documented here: 

 

https://docs.microsoft.com/en-us/power-bi/desktop-r-scripts

 

I only have experience using R visuals. I would recommend you start a new topic and get help from others, or contact support.




Proud to be a Super User!




Looks like sentimentr library/package is not supported by PowerBI at this time.

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors