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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
jigr69
Frequent Visitor

@v-haibl-msft

 

Hi Herbert.

 

I've now updated Microsoft R from version 3.3.1. to 3.4.0 and finally to 3.4.1. but the charts in R studio are still coming out as they were, i.e. correctly, whereas the same chart in Power BI (despite also being updated recently Version: 2.50.4859.502 64-bit September 2017), is coming out incorrectly.

 

The chart isn't, as you can see, complicated or anything, just wondering why it is rendering so differently in the two versions.

 

Regards

jigr69
Frequent Visitor

@v-haibl-msft @Vicky_Song

 

It has been 12 days since the last response has been received from someone at Microsoft, is this still seen as an outstanding issue?

 

Just to reiterate, I have the latest version of Power BI and R Studio but still the issue is the same.

jigr69
Frequent Visitor