-2

If I am sub-setting using logical statements, is there a way of combining without using logical operators? i.e. is there a more effective way of doing the following:

train$TOD[train$Hour == 23 | train$Hour == 0 | train$Hour == 1 | train$Hour == 2]
zx8754
  • 52,746
  • 12
  • 114
  • 209

1 Answers1

0

With a reproducible example it could be great but I think that this code is what you are looking for:

train[train$Hour %in% c(0, 1, 2, 23), ]
SabDeM
  • 7,050
  • 2
  • 25
  • 38
  • You are welcome, but just a reminder for next time: help users to help you by providing a ***reproducible* example. Here you can find useful informations: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – SabDeM Jun 16 '15 at 13:29