How to call SPMF from R

Ask any questions, discuss or post suggestions for SPMF
Post Reply
User avatar
admin
Site Admin
Posts: 121
Joined: Tue Apr 05, 2022 12:47 am
Location: China
Contact:

How to call SPMF from R

Post by admin »

Hi all, I have written a new blog post about how to call SPMF as an external program from the R programming language.

You can read the post here: https://data-mining.philippe-fournier-viger.com/how-to-call-spmf-from-r/.

It is very easy. The code looks like this to run the Apriori algorithm and display the output file:

Code: Select all

#Set the working directory to the folder containing spmf.jar and the file contextPasquier99.txt 
setwd("C:\\Users\\philippe\\Desktop\\") 

#Call SPMF as an external program to run the Apriori algorithm 
system("java -jar spmf.jar run Apriori contextPasquier99.txt output.txt 40%")

# Read the output file line by line and print to the console
myCon = file(description = "output.txt", open="r", blocking = TRUE)
repeat{
  pl = readLines(myCon, n = 1) # Read one line from the connection.
  if(identical(pl, character(0))){break} # If the line is empty, exit.
  print(pl) # Otherwise, print and repeat next iteration.
}
close(myCon)
rm(myCon) 
I also wrote similar instructions to call SPMF as an external program from Python and how to call SPMF from C#.
Post Reply