1

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)
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • You should probably add a tag with the programming language you're using – Mel Dec 13 '18 at 09:55
  • If you're unable to provide a reproducible example (see [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)), you should at least show the structure of your data. You can e.g. use `str()` for that. – Roman Luštrik Dec 13 '18 at 10:37

1 Answers1

0

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
boski
  • 2,437
  • 1
  • 14
  • 30