Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Need help with the R script

Hi,

I have 2 columns in my dataset namely [name] and [mathscore] and i want to show the barchart with that but failed to do that.

Can anyone will tell how to write the syntax for this.

 

 

Thanks in Advance.

  • Hi Anonymous,

    Based on my test, you could use the ggplot function to show a barchart in Power BI:

    library(ggplot2)
    # Basic barplot
    p<-ggplot(data=dataset, aes(x=dataset$Name, y=dataset$mathscore)) +
      geom_bar(stat="identity")
    p

    Result:

    You could also download the pbix file to have a view.

     

    Regards,

    Daniel He

1 Reply

  • v-danhe-msft's avatar
    v-danhe-msft
    Microsoft Employee

    Hi Anonymous,

    Based on my test, you could use the ggplot function to show a barchart in Power BI:

    library(ggplot2)
    # Basic barplot
    p<-ggplot(data=dataset, aes(x=dataset$Name, y=dataset$mathscore)) +
      geom_bar(stat="identity")
    p

    Result:

    You could also download the pbix file to have a view.

     

    Regards,

    Daniel He