cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Memorable Member
Memorable Member

Re: Error in running an R script using sentimentr library in PowerBI

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

 

Highlighted
Frequent Visitor

Re: Error in running an R script using sentimentr library in PowerBI

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

Highlighted
Frequent Visitor

Re: Error in running an R script using sentimentr library in PowerBI

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.

 

Highlighted
Memorable Member
Memorable Member

Re: Error in running an R script using sentimentr library in PowerBI

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.

Highlighted
Frequent Visitor

Re: Error in running an R script using sentimentr library in PowerBI

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

 

Highlighted
Memorable Member
Memorable Member

Re: Error in running an R script using sentimentr library in PowerBI

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

Highlighted
Frequent Visitor

Re: Error in running an R script using sentimentr library in PowerBI

@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. 

Highlighted
Memorable Member
Memorable Member

Re: Error in running an R script using sentimentr library in PowerBI

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.

Helpful resources

Announcements
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Top Solution Authors