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.

R Visualisation not auto-populating data.frame in script editor - maybe a bug?

In the R Visualisation, the data.frame in the script editor should automatically populate as you add fields into the 'Values' pane. This isn't happening currently and so my script is erroring.

If I populate the data.frame myself with the required fields, the script works but there is no data in my chart, so it would seem that the data is not pulling through correctly.

I have R and R studio installed on my machine and Power BI is pointing to the correct directories.

 

I read a recent post by someone having the same issue so wonder whether this is a bug?

 

Status: New
Comments
v-chuncz-msft
Community Support

@Anonymous 

 

The latest version works fine for me. The generated dataframe is named dataset.

https://docs.microsoft.com/power-bi/create-reports/desktop-r-visuals#create-r-visuals-in-power-bi-desktop

Anonymous
Not applicable

@v-chuncz-msft that's very odd. When I add the fields to the values box, I get this:

louiza83_0-1631006722535.png

No dataframe is generated. I followed the exact walkthrough in the link you attached. Could it be something to do with by R Scripting options?

louiza83_1-1631006843579.png

 

I'm not sure what else it could be. 

 

MatBaker
Frequent Visitor

I also get the same issue, with no automated code being generated regardless of the combination of fields being used.

MatBaker_0-1631098341197.png

Tried initially with an older version of R (4.0.4) and R Studio. Then updated everything to the latest versions and still have the same issue.

 

 

MatBaker
Frequent Visitor

@Anonymous - managed to work through this, appears to be an issue with the data being added with the wrong type of inverted commas (at least for me) which was causing the data not to load correctly.

 

Have a look at @bice_cold 's solution on the following post:

https://community.powerbi.com/t5/Desktop/PBI-doesn-t-add-the-first-three-lines-of-the-script-when-I-press/m-p/157238

 

When I went through the screen on step 6 of:

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-r-ide

 

I had inverted comma's around the dataset. I removed them, coded the remainder of my plot within R-Studio to make sure it worked. I then saved this and also copied the code lines across to PowerBI. I had to run the script within PowerBI (play button on black bar R Script editor bar) before the visual would then work.

 

Anonymous
Not applicable

@MatBaker- thanks for you reply. However, I can't seem to get as far as step 6 in the document. Step 4 is my issue. See screenshot below:

 

louiza83_0-1631190360112.png

Step 4 in the doc says that the script at line 3 should be created automatically based on the fields selected in the 'Values' pane. This doesn't happen for me. 

 

I'm stumped. 

MatBaker
Frequent Visitor

@Anonymous  - The crux of my post was that you can work around this step, it's not critical to get the inbedded visual working. There was in enough in the first link I posted it explains how to do this.

1) Change the temporary storage location within PowerBI to a known location. This is the location that a temproary data file and your R Code for the visual is recorded.

2) Open the R file that gets saved in this temporary location directly in R-Studio. Check the load statement at the top, it will be something like this:

dataset = read.csv('/*file location here*/').

in my case it was

‘dataset‘ = read.csv('/*file location here*/').

Note that they are the wrong type of inverted commas so didn't load the data and as such I couldn't manipulate the data or generate a visual. This is the bit that actually loads the data and isn't shown in the script editor within PowerBI for some reason.

3) You can then generate your visual using the loaded dataset, the stuff in green is commented out so doesn't actually do anything and isn't necessary to create the visual. It's only included as an aid memoir.

Anonymous
Not applicable

@MatBaker - so sorry, I totally misunderstood your post. I will have a go at the above and see how I get on. 

iakotsel
Regular Visitor

@@louiza8 I had the same problem.

Just downloaded and installed the latest verions and it works fine now.