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
Bram
Regular Visitor

R script visual doesn't want to load in services

I have created an R script visual. It works fine in my desktop version of Power BI. Unfortunatly, after publishing my report online the R visual script won't load in my brower. The R script visual doesn't give an error. It just stop loading after a short time and remains white. 

 

I have only used packages that are support by R, namely "lattice" and "reshape". This is the first time that I'm using R I don't completely understand it yet.

This is the R code that I'm using:

 

### loading packages

if (!require("lattice")) {
install.packages("lattice", dependencies = TRUE)
library(lattice)
}
if (!require("reshape")) {
install.packages("reshape", dependencies = TRUE)
library("reshape")
}

my_palette <- colorRampPalette(c("red","yellow","green4"))(n = 3000)

aggdata <-aggregate(dataset, by=list(dataset$f_Y2,dataset$r_Y2),
FUN=mean, na.rm=TRUE)
format <- cast(aggdata, Group.1 ~ Group.2)
rowcolNames2 <- list(as.character(1:8), as.character(1:8))
rownames(format) <- format$Group.1
format$Group.1 <- NULL
RFM_matrix <- data.matrix(format)

# 1) Air Passengers #1
plot(1,1)
print(levelplot(RFM_matrix,
col.regions=my_palette,
xlab = "freqentie",
ylab = "recency",
main=" "))

title(main="Churn rate", line=3,adj=0.96)

 

Does anybody know what could be wrong?

6 REPLIES 6
v-jiascu-msft
Employee
Employee

Hi @Bram,

 

Can you run the script in the R console? Can you share a sample please? I tested it. I got some errors in the R console while it was fine in the Desktop. Maybe you need to check the codes. 

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello

 

Thank you for your help. I'm new to R and I don't really understand what you mean with "running the script in the R console". Is it the same as running the script in R studio? In R studio it runs normal, it just prints out the heatmap, :/. 

Hi @Bram,

 

Yes, R console is one part of the R studio where you run the script. Can you share a dummy sample of the dataset? BTW, filing a support ticket is also a good idea.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello Dale

 

Thank you for the tip, I have submitted a support ticket. Here is a dummy dataset that can be used as imput for the R visual:

 

CustomerID f_Y2 r_Y2 ChurnedY2-Y3_int
11 1 1 0.728369
21 2 1 0.696333
31 3 1 0.636492
41 4 1 0.619205
51 5 1 0.556818
61 6 1 0.522727
71 7 1 0.593750
81 8 1 0.684210
12 1 2 0.740620
22 2 2 0.683418
32 3 2 0.598181
42 4 2 0.564727
52 5 2 0.536809
62 6 2 0.443298
72 7 2 0.571428
82 8 2 0.523809
13 1 3 0.680983
23 2 3 0.564087
33 3 3 0.437888
43 4 3 0.411764
53 5 3 0.304347
63 6 3 0.288343
73 7 3 0.200000
83 8 3 0.500000
14 1 4 0.681884
24 2 4 0.550000
34 3 4 0.395086
44 4 4 0.348341
54 5 4 0.260107
64 6 4 0.207272
74 7 4 0.107594
84 8 4 0.226415
15 1 5 0.697110
25 2 5 0.542549
35 3 5 0.398890
45 4 5 0.323045
55 5 5 0.258655
65 6 5 0.212389
75 7 5 0.144970
85 8 5 0.185950
16 1 6 0.674071
26 2 6 0.541830
36 3 6 0.367766
46 4 6 0.303912
56 5 6 0.212629
66 6 6 0.148205
76 7 6 0.106830
86 8 6 0.115459
17 1 7 0.631592
27 2 7 0.488593
37 3 7 0.309644
47 4 7 0.224320
57 5 7 0.154119
67 6 7 0.102636
77 7 7 0.054389
87 8 7 0.026390
18 1 8 0.621828
28 2 8 0.453608
38 3 8 0.291201
48 4 8 0.224618
58 5 8 0.159786
68 6 8 0.100552
78 7 8 0.059558
88 8 8 0.024722

 

Best regards, Bram

Bram
Regular Visitor

Someone has found the solution for me. There is a weird bug in the lattice package in services. The problem was apparrantly in the following piece of code.

 

print(levelplot(RFM_matrix,
col.regions=my_palette,
xlab = "freqentie",
ylab = "recency",
main=" "))

 

If you remove the space in the title it works. This gives:

 

print(levelplot(RFM_matrix,
col.regions=my_palette,
xlab = "freqentie",
ylab = "recency",
main=""))

 

Does anybody know why this could be the case? 

Greg_Deckler
Super User
Super User

I would submit this as a support issue. If you have a Pro account it is free. Go to https://support.powerbi.com. Scroll down and click "CREATE SUPPORT TICKET".


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors
Top Kudoed Authors