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
NielsDecoene
Helper I
Helper I

R issue how do i plot this.

Hey,

I have the following table in my Power BI. I want to create an R Visual out of this.

ThroughputLabelThroughputAgegroup
611Assess reimbursement1-3 Maanden
1191Assess reimbursement3-6 Maanden
104Authorized3-6 Maanden
148Cancelled1-3 Maanden
765Cancelled3-6 Maanden
4215Closed0-14 Dagen
57098Closed1-3 Maanden
14180Closed15-30 Dagen
26631Closed3-6 Maanden
14813Closed6-12 Maanden
52347ClosedGroter dan 12 maanden
1565Dispatched1-3 Maanden
56Dispatched15-30 Dagen
391Dispatched3-6 Maanden
107Intake1-3 Maanden
805Ready for closure1-3 Maanden
111Ready for closure3-6 Maanden

 

So i proceded to install all the correct R installations and packages, i produced some R shaping to the table :

> str(dataset)
'data.frame': 17 obs. of 3 variables:
$ Throughput : int 611 1191 104 148 765 4215 57098 14180 26631 14813 ...
$ Label : Factor w/ 7 levels "Assess reimbursement",..: 1 1 2 3 3 4 4 4 4 4 ...
$ ThroughputAgegroup: Factor w/ 6 levels "0-14 Dagen","1-3 Maanden",..: 2 4 4 2 4 1 2 3 4 5 ...
> test <- cast(dataset, Label ~ ThroughputAgegroup, mean, value = 'Throughput')
> test
To get the following table:

Label
0-14 Dagen1-3 Maanden15-30 Dagen3-6 Maanden6-12 MaandenGroter dan 12 maanden 
        
1
Assess reimbursement
NaN
611
NaN
1191
NaN
NaN
2
Authorized
NaN
NaN
NaN
104
NaN
NaN
3
Cancelled
NaN
148
NaN
765
NaN
NaN
4
Closed
4215
57098
14180
26631
14813
52347
5
Dispatched
NaN
1565
56
391
NaN
NaN
6
Intake
NaN
107
NaN
NaN
NaN
NaN
7
Ready for closure
NaN
805
NaN
111
NaN
NaN

 

Now I want to visualize this, when i try plotting this using:

corrplot(test, method = "circle", tl.cex=0.6, tl.srt = 45, tl.col = "black", type= "upper", order="hclust")

to get a nice visualisation i'm prompted with the following error: 
Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow = nr, :
length of 'dimnames' [2] not equal to array extent
In addition: Warning message:
In Ops.factor(left, right) : ‘<’ not meaningful for factors

 

Is there any way to visualize this? So that for each match in the matrix a Cirlce with a shape is created? NaN values can be blank.

 

Tyvm in advance

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Is ggplot going to be better for what you need - e.g.

 

library(ggplot2) #Required for ggplot

ggplot(dataset, aes(x=`ThroughputAgegroup`, y=`Label`)) +
  geom_point(size=10, alpha=0.1) +
  geom_text(aes(label=`Throughput`), size=3) 

You'll still need to work with the formatting - e.g. in my quick test, I couldn't get the X axis on top.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Is ggplot going to be better for what you need - e.g.

 

library(ggplot2) #Required for ggplot

ggplot(dataset, aes(x=`ThroughputAgegroup`, y=`Label`)) +
  geom_point(size=10, alpha=0.1) +
  geom_text(aes(label=`Throughput`), size=3) 

You'll still need to work with the formatting - e.g. in my quick test, I couldn't get the X axis on top.

Thanks alot Steve, i'll start right away to see what the pieces of code do so I can apply my formatting. 

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.