Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Community Champion
Community Champion

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

 

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.

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

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.

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.