Open Side Menu
Skip to contentBrand Logo
Forums
Inspiration
Ideas
Communities
Blogs
Learning
Support
RegisterSign In
  1. Microsoft Fabric Community
  2. Power BI forums
  3. Galleries
  4. R Script Showcase
Sharon's avatar
Sharon
Microsoft Employee
10 years ago

Association Rules

Description Association rules are ideal to quicly derive insights from large datasets.  The rules are autmatically detected and visualized.    Prerequisites (The sample .pbix files will not...
ScriptInstallPackagesWithWorkaroundsAssorules.R2 KB
Association Rules Showcase_1.0.2.pbix1.1 MB
Advanced Analytics Visualizations
Anonymous's avatar
Anonymous
Not applicable
10 years ago

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: Matrix

Attaching package: 'arules'

The following objects are masked from 'package:base':

    abbreviate, write

Error: could not find function "as"
Execution halted

Details:
    DataSourceKind=R
    DataSourcePath=R
    Message=R script error.
Loading required package: Matrix

Attaching package: 'arules'

The following objects are masked from 'package:base':

    abbreviate, write

Error: could not find function "as"
Execution halted

    ErrorCode=-2147467259
    ExceptionType=Microsoft.PowerBI.Radio.RScriptRuntimeException

  • Anonymous's avatar
    Anonymous
    Not applicable
    10 years ago

    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.

     

     

     

    • patoduck's avatar
      patoduck
      Helper III
      9 years ago

      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

       

       

      Dataset.xlsx11 KB
      • boefraty's avatar
        boefraty
        Microsoft Employee
        9 years ago

        Hi,
         
        The function "read.transactions"  reads a transaction data file from disk and creates a transactions object.  The error you get indicates that R could not open the file for reading.
         
         
        1) Save your excel as CSV for example to :  "c:\\Users\\someone\\Downloads\\try.csv
        2) Run
        txn <- read.transactions("c:\\Users\\boefraty\\Downloads\\try.csv", rm.duplicates= TRUE,format='single', sep='','',cols =c(2,1))

        Beside this, you should make sure that your data is a transaction object: to store a binary incidence matrix, item labels, and optionally transaction IDs and user IDs.  Check  your format is "single" or "basket"
         
        You are welcome to continue and discuss this example with me via email: [email protected]   or here

  • © 2026 Microsoft
  • Manage cookies
  • Privacy & cookies
  • Terms of use
  • Trademarks
Your Privacy Choices Consumer Health Privacy