2

I want to do a classification analysis on a voting dataset. I found in the UCI repository but I am having difficulty pre-processing it to be able to use the arules package in r. So the data looks partially like this.

party,      voting.issue1,  voting.issue2,  voting.issue3
republican, n,              y,              n
republican, n,              y,              n
democrat,   ?,              y,              y

After importing the data using "read.csv". I tried to use it directly as I read in the "Adult" dataset examples but I got the error

"Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘itemFrequencyPlot’ for signature ‘"data.frame"’"

I also tried this by changing the whole data to a binary matrix using excel, i.e. removed the party column and added republican and democrat columns with binary values and also converting the Ys, Ns and question marks in the other columns to 1s,0s and NAs respectively. I keep getting the same error. Can anyone suggest any preprossing functions or tutrials I can use to use the itemFrequencyPlot and Apriori functions.

Sophonias
  • 874
  • 5
  • 16
  • 38
  • Can you provide the URL for the UCI repository you downloaded? Second, can you show the code the created "data.frame" and the code you used to call the itemFrequencyPlot? – lawyeR Mar 26 '15 at 10:52

1 Answers1

0

You can try this solution or simply try to coerce your data frame in transactions with the following code and than use it in the itemFrequencyPlot function:

trans <- as(df, "transactions")
lucazav
  • 858
  • 9
  • 24