cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mischelin11 Frequent Visitor
Frequent Visitor

R function set.seed() does not work in Power BI R script visual

 
Hi
 

I need to compute and visualize cluster analysis from R in Power BI desktop. I use set.seed()function to prevent clusters from changing over time. I run this code first in Power BI Desktop and next time i publish it and run it in Power BI services. And here is the problem, because in Power BI desktop it make different (different order) clusters then in Power BI services. Is it possible that the problem is in the set.seed function?

A part of R code is:

set.seed(123)
km.res <- kmeans(scale(costs_noout_of), 4, nstart = 25)
dd <- cbind(costs_noout_all , cluster = km.res$cluster)
grid.table(ddply(dd, .(cluster), nrow))

And result is a table where is only numbers of clusters and counts of observations in that clusters, which i need in the following calculations.

Can anyone helps me?

3 REPLIES 3
Community Support Team
Community Support Team

Re: R function set.seed() does not work in Power BI R script visual

@mischelin11,

 

If convenient, please elaborate and share a more complete example for a quick test.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
mischelin11 Frequent Visitor
Frequent Visitor

Re: R function set.seed() does not work in Power BI R script visual

 

 Hi @v-chuncz-msft,

 

I dont know, how to add more complete example for this issue.

I can only add two graphical results, first is from Power BI services and second is from Power BI Desktop. As you can see, these results are a little different.

 

Result from Power BI services:

Capture.PNG

 

Result from Power BI Desktop:

Capture2.PNG

 

 

Community Support Team
Community Support Team

Re: R function set.seed() does not work in Power BI R script visual

@mischelin11,

 

This seems to be caused by sorting. Check if you could specify the sort order in R.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)