1
votes

I am trying to make a subset with with two different variables, however when I run this code:

progressive.vote.demo <- subset(dbj, subset == progressive.vote & republican == 0)

it comes up with this error message:

Error in subset == progressive.vote : comparison (1) is possible only for atomic and list types

This is so I can make a table to run a barplot:

democrats.table <- table(democrats$judge.birthyear == "before 1935",
democrats$judge.birthyear == "from 1935", dbj$progressive.vote)

barplot(democrats.table)
1
You should probably add a tag with the programming language you're using - Mel
If you're unable to provide a reproducible example (see here), you should at least show the structure of your data. You can e.g. use str() for that. - Roman Luštrik

1 Answers

0
votes

Could it be you are trying to pass a variable instead of a character string (say "progressive.vote")? More clarification would be welcomed.

dbj=as.data.frame(cbind(subset=c(rep("progressive.vote",2),rep("conservative.vote",2)),republican=c(0,1,0,1)))
dbj
     subset              republican
[1,] "progressive.vote"  "0"       
[2,] "progressive.vote"  "1"       
[3,] "conservative.vote" "0"       
[4,] "conservative.vote" "1"    

subset(dbj, subset == "progressive.vote" & republican == 0)
        subset republican
1 progressive.vote          0