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

Reply
paltus
Frequent Visitor

R script visual not working correctly in Service

Hi, 

 

I've created a R visual. Everything is working fine in desktop. 
But in service i get only Data, not Data + CR
If i write geom_text like this:

geom_text(aes(label=paste(dfr$'CR')
Then i get error: Aesthetics must be either length 1 or the same as the data (13): label, x, y  



333.JPG
222.JPG
dataset example:

Data             CR
2019-01-01 50000
2019-01-03 60000
2019-01-02  40000
2019-01-04 30000
2019-01-05 21000


# dataset <- data.frame(Data, CR)
# dataset <- unique(dataset)
 
Sys.setlocale("LC_TIME", "English")
library(ggplot2)


dfr <- dataset
 
 
dfr$day <- factor(strftime(as.POSIXlt(dfr$Data,format = "%Y-%m-%d"),format="%A"),levels=c("Sunday","Saturday","Friday","Thursday","Wednesday","Tuesday","Monday"))
dfr$week <- factor(strftime(as.POSIXlt(dfr$Data,format = "%Y-%m-%d"),format="%V"))
dfr$month <- factor(strftime(as.POSIXlt(dfr$Data,format = "%Y-%m-%d"),format="%B"),levels=c("January","February","March","April","May","June","July","August","September","October","November","December"))
dfr$ddate <- factor(strftime(as.POSIXlt(dfr$Data,format = "%Y-%m-%d"),format="%d"))



dfr$comment <- "Available"

dfr$comment <- factor(dfr$comment,levels=c("Available","Limited","Not available","Weekend"))


# plot
p <- ggplot(dfr,aes(x=week,y=day))+
geom_tile(aes(fill=comment))+
geom_text(aes(label=paste(ddate,dfr$'CR',sep ="
")))+
scale_fill_manual(values=c("#8dd3c7","#ffffb3","#fb8072","#d3d3d3"))+
facet_grid(~month,scales="free",space="free")+
labs(x="Week",y="")+
theme_bw(base_size=12)+
theme(legend.title=element_blank(),
panel.grid=element_blank(),
panel.border=element_blank(),
axis.ticks=element_blank(),
strip.background=element_blank(),
legend.position="top",
legend.justification="right",
legend.direction="horizontal",
legend.key.size=unit(0.4,"cm"),
legend.spacing.x=unit(0.3,"cm"))

plot(p)

 


How can I solve this?

 

Thanks in advance!

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

My initial thought on this is that whatever R module geom_text is in has a different version on the Service than the one that you are using locally.

 

You could check the Issues forum here:

https://community.powerbi.com/t5/Issues/idb-p/Issues

And if it is not there, then you could post it.

If you have Pro account you could try to open a support ticket. If you have a Pro account it is free. Go to https://support.powerbi.com. Scroll down and click "CREATE SUPPORT TICKET".



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.