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
mischelin11
Advocate I
Advocate I

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
v-chuncz-msft
Community Support
Community Support

@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.

 

 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

 

 

@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
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.