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
abhishekpati86
Helper III
Helper III

pch and col function not working in R using Power BI

Hi All,

 

Below is the plot function I am using to plot 2 columns where one is date range and other one is Numeric. 

 

Capture.JPG

 

I am getting the plot as desired but now I want to know 2 more things : -

 

1) Can anyone help me with why pch and col functions are not working in this plot. (highlighted below in red)

 

2) Can I get rid of the hh:mm:ss from the date range on my plot in X axis.

 

Thanks,

Abhishek 

1 ACCEPTED SOLUTION

Hi abhishekpati86,

 

The chart is only able to show the year range under R when using the as.date (date format) function in R.

 

d1 <- aggregate(dataset$sales ~as.Date(dataset$date,  orgin="%m/%d/%Y"), data=dataset,FUN=sum)

plot(d1,main="date Vs sales",pch=22,col="blue",xlab="date", ylab="sales",ylim=c(500,800))

 

The below is the as.date function reference:

https://stat.ethz.ch/R-manual/R-devel/library/base/html/as.Date.html

See the result:

 

4.PNG

 

 

Check and see if this would be helpful. I will also take a further look into the X range part, and if any helpful things, I will post back.

Regards

 

 

View solution in original post

10 REPLIES 10
abhishekpati86
Helper III
Helper III

Tagging @MattAllington

The list below covers what I know about R in Power BI

 

 

 

 

 

That concludes the list 🙂



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

That was a cheeky response. I would appreciate if you can point out anyone who can help 🙂

Can you post your full R script so I can see what modules you are using and any chance you can post some sample data? Also, what R runtime are you using?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hey,

 

Below is the rcode I am using.

 

d1 <- aggregate(dataset$Count ~ dataset$Completed_Date,data = dataset,FUN=sum)
plot(d1,main="Completed Date Vs Count of Course Test Takers",pch=22,col="blue",xlab="Completed Date",ylab="Count of Course Test Takers",ylim=c(0,1000))

 

I have loaded a bunch of packages on R (version 3.3.1) and here goes the sample data.

 

Capture.JPG

OK, just as another quick question, in your R IDE outside of Power BI Desktop does it work correctly?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi,

 

I haven't uploaded this particular dataset but normal pch and col commands works fine on other dataset in my R Desktop.

 

Thanks,

Abhishek 

@Greg_Deckler

 

Hi All,

 

I was able to solve the last issue but now I am not able to format the X axis dates to mm-dd-yyyy  format.

 

Currently my date field in x axis is showing in yyyy-mm-dd hh:mm:ssss.

 

Capture.JPG

 

Thanks,

Abhishek 

Hi abhishekpati86,

 

The chart is only able to show the year range under R when using the as.date (date format) function in R.

 

d1 <- aggregate(dataset$sales ~as.Date(dataset$date,  orgin="%m/%d/%Y"), data=dataset,FUN=sum)

plot(d1,main="date Vs sales",pch=22,col="blue",xlab="date", ylab="sales",ylim=c(500,800))

 

The below is the as.date function reference:

https://stat.ethz.ch/R-manual/R-devel/library/base/html/as.Date.html

See the result:

 

4.PNG

 

 

Check and see if this would be helpful. I will also take a further look into the X range part, and if any helpful things, I will post back.

Regards

 

 

@v-micsh-msft -- Thanks Michael, it did solve the issue. My pch and col functions that didn't work earlier have also started responding. 

 

Cheers,

Abhi

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.