Implement PRISM algorithm in R