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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Shawn_Eary
Advocate IV
Advocate IV

Get User Input in R Script Visual

I have the following R Code which I run in Power BI Desktop:

 

# References:
# https://www.tutorialspoint.com/r/r_pie_charts.htm
# https://www.rdocumentation.org/packages/svDialogs/versions/1.0.0/topics/dlg_input
library(svDialogs)

title <- dlgInput("Enter Title for Report")$res
pie ( c(2, 3, 2), c("dog", "cat", "moose"), main = title)

 

It displays the Pie Chart just fine in Power BI, but it never prompts for user Input so the title of the report doesn't get updated.

 

Why isn't the Power BI hosted R Script prompting me for user input?

BTW: When I go to insert code into posts on this forum, I don't see options for F#, Power Query M, DAX or R.  All of these lanaguages are relavent to this forum.  I picked Java to display the above R code so I could get "Pretty Printing".

 

 

5 REPLIES 5
vitaly
Advocate II
Advocate II

I realize this is a very old thread and the OP has probably long since figured out the solution.

 

Having said that, this is a known limitation in R integration in Power BI.

 

From https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-r-scripts: "Interactive calls in the R script, such as waiting for user input, halts the script’s execution."

 

Anonymous
Not applicable

Hi @Shawn_Eary ,

Whether your problem has been resolved? If yes, could you please mark it as Answered? So it will help others if they face the similar problem with you. Thank you.

Best Regards

Rena

Anonymous
Not applicable

Hi @Shawn_Eary ,

Please try to update your R code as below:

# References:
# https://www.tutorialspoint.com/r/r_pie_charts.htm
# https://www.rdocumentation.org/packages/svDialogs/versions/1.0.0/topics/dlg_input
library(svDialogs)

title <- readline(prompt="Enter Title for Report ")$res
pie ( c(2, 3, 2), c("dog", "cat", "moose"), main = title)

 

Best Regards

Rena

 

@Anonymous- readline doesn't work when run in an R Visual either.  It works fine from the R Console but it doesn't work inside an R Visualization for Power BI Desktop 2.79.5768.721 64-bit (March 2020).  The prompt is simply skipped and the report is displayed with no title. 

I don't know if other versions of Power BI Desktop are affected but I suspect they are.

 

There needs to be an easy way to do the following:

  1. Create an R Visualization with no data source
  2. Use a standardized R GUI Toolkit to grab "forms" data from the user
  3. Submit that user input to a pameterized REST API without running into CORS violations and/or issues
  4. Process the data returned from the REST API and display it with the built in charting capabilities of R.

NOTE: Will the developers of this website please turn spell check on for this TextArea?  All they should have to do is flip a switch...
https://davidwalsh.name/spellcheck

 

This is slightly tangential, but when I run this RScript in a visualization, I also can't find the output of the print statements...

 

 

speed <- c(2, 3, 4)
drag <- c(4, 9, 16)
print(speed)
print(drag)
plot(speed, drag)

 

 

The script prints the speed and drag vectors out fine when run via cmd.exe using RScript.exe, but when I run it in Power BI, I can't find the print output...

BTW: I tried posting an unrelated question with a few tables more than once over the course of several days and this Forums WebApp "crashed" on me at least twice thereby throwing out the contents of the questions that I had spent notable time on...   While it is certainly more competitive and "vicious", I'm beginning to wonder if the Power BI community would be better served if we completely abolished this Forum and required all Power BI users to go through StackOverflow.  I understand the StackOverflow culture can sometimes feel "hostile" but this WebApp has serious usability issues...  The SO interface is much more efficient and easier to use.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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