Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Possible bug when using R charts

I have a script which when entered into Microsoft R Open version GUI I get one chart displayed which is correct. However, when using precisely the same code within Power BI, the segments of the pie chart do not colorate with those from the R GUI?

The code is pasted below:

 

 

library(ggplot2)
library(scales)

blank_theme <- theme_minimal() +
	theme(
		plot.title = element_text(size=16, face="bold"),
		axis.title = element_blank(),
		axis.title.x = element_blank(),
		axis.title.y = element_blank(),
		axis.ticks = element_blank(),
		axis.text.y = element_blank(),
		axis.text.x = element_text(color='black'),
		panel.grid = element_blank()
	)

df <- data.frame(
	value = c(6019, 2211, 314),
	Legend = c("Registered Within", "Registered On", "Registered Out")
)

p <- ggplot(df, aes(x=1, y=value, fill=Legend))+
	ggtitle("Registered DETs 4am") +
	coord_polar(theta='y')

y.breaks <- cumsum(df$value) - df$value / 2

p <- p +
	scale_fill_manual(values=c("#FD625E", "#F2C80F", "#01B8AA"))+
	geom_bar(stat="identity", color="black") +
	guides(fill=guide_legend(override.aes=list(colour=NA))) +
	blank_theme +
	theme(axis.text.x=element_blank()) +
	scale_y_continuous(
			breaks = y.breaks,
			labels=df$Legend
	) +
	geom_text(
		aes(
			y = value / 3 + c(0, cumsum(value)[-length(value)]), 
			label = format(value/sum(value)*100, digits=2, nsmall=2)
		),
		size=4
	) +
	labs(
		title="Registered DETs - 04:00"
	)

p

 

Everything is contained within the code above, for this to be tested.

 

In the R GUI, the order is "Registered In", "Registered On", "Registered Out" along with the correct data, however, in Power BI, the labels are ordered correctly, but the segments are drawn in the order of "Registered In", "Registered Out", "Registered On".

 

Does anyone know why this is the case?

 

Status: Accepted
Comments
v-haibl-msft
Microsoft Employee

@jigr69

 

Could you please post the screenshot for the chart in R Open version GUI, and share the PBIX file through online file service like OneDrive?

 

Best Regards,
Herbert

Vicky_Song
Impactful Individual
Status changed to: Needs Info
 
jigr69
Frequent Visitor

Here's the two images from the two different sources, as you can see the charts are different despite using the same information. PIBX file to follow.

 

 

From Power BIFrom Power BIFrom R StudioFrom R Studio

jigr69
Frequent Visitor
v-haibl-msft
Microsoft Employee

@jigr69

 

I’ve reported it internally to Power BI Team: CRI 46580390
I’ll post here once I get any update about it.

 

Best Regards,
Herbert

Vicky_Song
Impactful Individual
Status changed to: Accepted
 
jigr69
Frequent Visitor

Thanks for that, it'll be good to that one fixed! Smiley Very Happy

v-haibl-msft
Microsoft Employee

@jigr69

 

I've got response from the Product Team.

 

Please use MRO R version in powerbi desktop as well. For this purpose go to : 

File -> Options and settings -> Options -> R scripting

and change R installation directory to MRO version.

running script visual now should result the expected image.

 

Best Regards,
Herbert

jigr69
Frequent Visitor

Thanks for that Herbert.

 

But on checking it looks like I'm already using MRO Version, version 3.3.1.

 

v-haibl-msft
Microsoft Employee

@jigr69

 

Could you please try with the latest version of MRO? It seems that 3.4.0 is already available.

 

Best Regards,
Herbert