Forum Discussion

davidsimm10's avatar
davidsimm10
Frequent Visitor
5 years ago
Solved

R visualisation to use imported tables

I am trying to use the 'R' visualisation in PowerBI. I have installed RStudio, linked PowerBI to R etc.

 

I am hoping that I can use the fields from a 'Get Data' import. I have pulled in data from a SQL database, used the 'R' visualisation and tried to code the following...

 

dataset <- data.frame(CountSpellID, WardLocalDescription)
dataset <- unique(dataset)
View(dataset)
 
It returns the error.
 
Error in data.frame(CountSpellID, WardLocalDescription) ;
object 'CountSpellID' not found
Execution halted
 
Can someone please tell me where I am going wrong?
  • You are supposed to drag existing fields from your Power BI data model into the values area of the R visual, so that they can be added to the dataframe.  Don't modify that part of the script or manually specify any fields.

2 Replies

  • You are supposed to drag existing fields from your Power BI data model into the values area of the R visual, so that they can be added to the dataframe.  Don't modify that part of the script or manually specify any fields.

    • davidsimm10's avatar
      davidsimm10
      Frequent Visitor

      This worked thank you! I didnt quite understand what you meant. I presumed because of the hashtags that it wouldnt work properly. Huge thank you

       

      # The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:

      # dataset <- data.frame(CountOfPatients, Division)
      # dataset <- unique(dataset)

      # Paste or type your script code here: