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)