Page 1 of 1

How to call SPMF from R

Posted: Tue Jan 10, 2023 3:29 am
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#.