Shravan Vasishth wrote:>
> Hello everybody,
>
> I'm trying to subset a data frame "foo", which looks like
this:
>
> sent cond raw V1
> 10 2 A 614 7
> 11 2 A 724 6
> 12 2 A 641 5
> 13 2 A 665 9
> 33 5 B 510 7
> 34 5 B 659 7
> 35 5 B 607 6
> 37 5 B 467 8
> 38 5 B 586 9
> 39 5 B 523 10
> 57 8 C 858 8
> 58 8 C 513 9
> 59 8 C 739 7
> 60 8 C 699 7
> 61 8 C 585 4
> 79 11 D 485 8
> 80 11 D 704 8
> 81 11 D 544 7
> 82 11 D 461 7
> 83 11 D 838 8
> 84 11 D 655 13
> 85 11 D 568 6
> 107 15 A 467 7
> 108 15 A 680 7
> 110 15 A 741 8
> 130 19 B 686 7
> 131 19 B 717 6
> 132 19 B 495 8
> 133 19 B 480 4
> 134 19 B 376 7
> 135 19 B 470 9
> 148 21 C 443 6
> 149 21 C 771 8
> 150 21 C 790 8
> 151 21 C 653 8
> 152 21 C 547 7
> 173 25 D 550 7
> 174 25 D 444 7
> 175 25 D 491 8
> 176 25 D 1038 7
> 177 25 D 1003 9
> 178 25 D 661 13
> 179 25 D 645 10
> 193 28 A 652 7
> 194 28 A 846 6
> 195 28 A 571 5
> 196 28 A 467 8
> 197 28 A 597 10
> 206 31 B 474 7
> 207 31 B 534 7
> 208 31 B 545 7
> 209 31 B 610 5
> 210 31 B 443 8
> 211 31 B 454 12
> 212 31 B 420 10
> 231 35 C 549 7
> 232 35 C 527 6
> 233 35 C 408 7
> 234 35 C 394 8
> 235 35 C 396 10
> 244 37 D 574 8
> 245 37 D 711 8
> 246 37 D 457 8
> 247 37 D 556 6
> 248 37 D 399 8
> 249 37 D 425 13
> 250 37 D 371 7
> 259 39 A 644 6
> 260 39 A 872 8
> 262 39 A 1685 9
> 278 42 B 551 6
> 279 42 B 611 7
> 280 42 B 672 8
> 281 42 B 650 4
> 282 42 B 576 9
> 283 42 B 559 14
> 305 46 C 566 9
> 306 46 C 433 6
> 307 46 C 315 6
> 308 46 C 1088 9
> 309 46 C 463 6
> 320 48 D 481 6
> 321 48 D 642 8
> 322 48 D 548 8
> 323 48 D 507 7
> 324 48 D 406 9
> 325 48 D 380 13
>
> When I do
>
> >subset(foo, V1 > 5)
>
> (I.e., when I try to remove all rows with values 5 or less in column V1)
> I get this error message:
>
> Warning message:
> ">" not meaningful for factors in: Ops.factor(V1, 5)
The reason for the error is what R tells you: V1 is a factor (and not
numeric) and therefore ">" is not meaningful.
If V1 is not a factor you should change it to a numeric vector and use
the command above. Or you could do something like
subset(foo, levels(V1) > 5)
which should give the desired result.
Z
> I have the same problem with ">".
>
> However, it works fine if I do:
>
> >subset(foo, V1 != 1 & V1 != 2 & V1 != 3 & V1 != 4 & V1
!= 5)
>
> If I try the same thing with the airquality example in the help (?subset),
> the inequality works fine:
>
> >subset(airquality, Temp > 80)
>
> ...
>
> Thanks in advance,
>
> --
> Shravan Vasishth
> Dept. of Linguistics, OSU
> 222 Oxley Hall, 1712 Neil Ave.
> Columbus, OH 43210-1298
> USA
>
> URL: http://ling.ohio-state.edu/~vasishth
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._