Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

R Script arules

Hi there

I ran the following script in R studio and it runs successfully.

 

adult = data(Adult)

DATAFRAME(head(Adult))
DATAFRAME(head(Adult), setStart = '', itemSep = ' + ', setEnd = '')

rules <- apriori(Adult,
                 parameter = list(supp = 0.5, conf = 0.9, target = "rules"))
rules <- head(rules, by = "conf")


DATAFRAME(rules)

DATAFRAME(rules, separate = TRUE)
DATAFRAME(rules, separate = TRUE, setStart = '', itemSep = ' + ', setEnd = '')

 

When I run this through Get Data in Powerbi It doesnt work.

 

I saw this video https://www.youtube.com/watch?v=CzeeTXvun5c&app=desktop

Following similar concept except different dataset this seems to work and I dont know why.  I tried different R version from 3.2.5 to 3.4.1 but not worked. I have arules, Matrix and methods installed on all version.

 

I am on PowerBI desktop July update.

 

Any advice would be greateful.

 

Pedzilla

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

you have to add 2 lines of code to your R scrip:

 

the first line has to be
library("arules");

this "loads" the arules library into the Power BI session and you have to explicitly return a dataframe to Power BI, this dataframe will then be treated as a table, so for this reason your last 3 lines of your R script shoud look like this:


df1 <- DATAFRAME(rules)
df2 <- DATAFRAME(rules, separate = TRUE)
df3 <- DATAFRAME(rules, separate = TRUE, setStart = '', itemSep = ' + ', setEnd = '')

 

Then the Get Dialog will present you 3 dataframes:

 

2017-07-15_13-13-37.png

 

Hope this helps



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

1 REPLY 1
TomMartens
Super User
Super User

Hey,

 

you have to add 2 lines of code to your R scrip:

 

the first line has to be
library("arules");

this "loads" the arules library into the Power BI session and you have to explicitly return a dataframe to Power BI, this dataframe will then be treated as a table, so for this reason your last 3 lines of your R script shoud look like this:


df1 <- DATAFRAME(rules)
df2 <- DATAFRAME(rules, separate = TRUE)
df3 <- DATAFRAME(rules, separate = TRUE, setStart = '', itemSep = ' + ', setEnd = '')

 

Then the Get Dialog will present you 3 dataframes:

 

2017-07-15_13-13-37.png

 

Hope this helps



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.