Association Rules
Description
Prerequisites (The sample .pbix files will not work without these prerequites completed)
1. Install R Engine
Power BI Desktop does not include, deploy or install the R engine. To run R scripts in Power BI Desktop, you must separately installR on your local computer. You can download and install R for free from many locations, including the Revolution Open download page, and the CRAN Repository.
2. Install the required R packages.
Download the R script attached to this message and run it to install all required packages on your local machine.
Required R packages:
arules, arulesViz, grDevices, gridExtra, grid, methods
Tested on:
CRAN 3.3.1, MRO 3.3.0, , powerbi.com
Legal Disclaimers:
Terms of Service and Third Party Programs.
24 Replies
- AnonymousNot applicable
Hi
I wonder if you can advice that what Im trying to acheive is possible.
I wanted to transform my dataset to transactions using a simple R script below
library(arules)dd = as(dataset, "transactions")
df = as.data.frame(as(dd, "matrix"))However I got an error message beolow. Can you please help what this error actually mean and how to fix it?
DataSource.Error: ADO.NET: R script error.
Loading required package: MatrixAttaching package: 'arules'
The following objects are masked from 'package:base':
abbreviate, write
Error: could not find function "as"
Execution haltedDetails:
DataSourceKind=R
DataSourcePath=R
Message=R script error.
Loading required package: MatrixAttaching package: 'arules'
The following objects are masked from 'package:base':
abbreviate, write
Error: could not find function "as"
Execution haltedErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Radio.RScriptRuntimeException- AnonymousNot applicable
Answered by own question!
library(arules)
library(methods)
data(dataset)
dd1=as(dataset,"transactions")
trans=dd1
AdultData=as.data.frame(as(dd1, "matrix"))
AdultData=cbind(id=1:nrow(AdultData),AdultData)replace data(Adult) with data(dataset) and R does the rest!.. didnt have eyes for details there.
- patoduckHelper III
Hi,
I have a table with 2 Columns ID and Product.
I want to Edit the Script in R, but I can't get it to work
How should it be the read.transactions statement?
> txn <- read.transactions(dataset, rm.duplicates= TRUE,format='basket',sep='','',cols =1)
But I get this error...
Error in readLines(file, encoding = encoding) : 'con' is not a connection
- baferrieNew Member
Hello, I downloaded the association rules custom viz and succesfully have it working with the data. I was wondering though if there was any way we could sort the rules based on the RHS? I tried adding a filter, but what that did was exclude the data from ever getting to the association rules algorithm. Is there a way to sort the association rules without excluding data?
- boefratyMicrosoft Employee
Do you want to sort by second column?
- boefratyMicrosoft Employee
Side branch solution for this feature:
https://github.com/boefraty74/PowerBI-visuals-assorules-1/tree/assorulesWithTextFiltersI added two text parameters, comma separated strings to be searched inside RHS string rule (using OR operator)
- MAAbdullah47Helper V
Please tell us how you draw this table.
- karaoanKudo Kingpin
- boefratyMicrosoft Employee
The problem is with "ISLR" package it is required by R connector (not R visual), so you have two workarounds:
1) Don't do refresh
2) call command
install.packages("ISLR")from any R console
- ironryan77Kudo Commander
Great job on this visual! But I can't figure out how you created your dataset? I'm looking at the sample PBIX file and it looks like the selected fields are total counts. So in my PBIX file I counted the total values by creating a measure:
MPPL2 = CALCULATE(COUNT(IRC_Metric_RSA_Refresh[PPL2]), FILTER(IRC_Metric_RSA_Refresh, [PPL2]="AUTO"))
But when I add this measure to the visual in my own PBIX file, it doesn't allow Basic filtering and it doesn't display in my PBIX. How can I mimic your behavior in my PBIX file?
- ironryan77Kudo Commander
Also this is the error I'm getting:
- boefratyMicrosoft Employee
Hi ironryan77,
Please send me a PBIX, I will see what can be done