How do you run R script visual in Power BI Service?

0 votes

I have created a R visual that loads data and makes a calendar. The following script is working fine in Power BI Desktop but not in Power BI Service
This is the error which I am getting:

as.POSIXlt.default(x, tz = tz)

I don't know how to convert 'x' to class "POSIXlt"
Date is just a table of dates:

Date:

2019-01-14
2019-01-15
2019-01-16
2019-01-17
2019-01-18

library(ggplot2)

p <- ggplot(dfr,aes(x=week,y=day))+geom_text(aes(label=paste(ddate,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)
May 21 in Power BI by Phalguni
• 930 points

edited May 22 by Omkar 19 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hi,

It seems that your data format not recognized correctly if you use Power BI Service. Please refer code functions to convert these date values :

library(ggplot2)

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

# plot
p <- ggplot(dfr,aes(x=week,y=day))+
geom_text(aes(label=paste(ddate,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)

Hope This Helps!!

answered May 21 by Avantika
• 1,380 points

edited May 22 by Omkar

Related Questions In Power BI

0 votes
1 answer

How do you create visualizations in Power BI?

Visualizations in Power BI Visuals are the end-result ...READ MORE

answered Feb 27 in Power BI by Phalguni
• 930 points
31 views
0 votes
1 answer

How do you add a slicer from different table in Power BI?

In order to add a slicer from ...READ MORE

answered Mar 5 in Power BI by Phalguni
• 930 points
28 views
0 votes
1 answer
0 votes
1 answer

How do you schedule Data Refresh in Power BI?

Hi, Following could be the reasons why this ...READ MORE

answered May 21 in Power BI by Avantika
• 1,380 points
20 views
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,060 points
53 views
0 votes
1 answer

Unable to install connector for Power Bi and PostgreSQL

I think the problem is not at ...READ MORE

answered Aug 21, 2018 in Power BI by nirvana
• 3,060 points
406 views
+2 votes
2 answers

Migrate power bi collection to power bi embedded

I agree with Kalgi, this method is ...READ MORE

answered Oct 11, 2018 in Power BI by Hannah
• 14,080 points
70 views
0 votes
1 answer

Connect power bi desktop to dataset and create custom reports

Yes using Power BI REST API to ...READ MORE

answered Sep 18, 2018 in Power BI by Kalgi
• 36,300 points
65 views
0 votes
1 answer

How do you create a link visual in Power BI?

You can easily create a link between ...READ MORE

answered Mar 8 in Power BI by Avantika
• 1,380 points

edited Mar 9 by Avantika 43 views
0 votes
1 answer

How do you use R visuals in Power BI Desktop?

Hi, In order to use R Visuals you ...READ MORE

answered Apr 10 in Power BI by Avantika
• 1,380 points
23 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.