filter data in R
How to Filter Data from a Table in R
Imagine you have a table below called "trains" and you want to filter Train to HWH
KJM <- filter(trains, To == "HWH")
TrainNo | From | To | DateofJourney |
12863 | HWH | YPR | 21-Nov-15 |
12245 | HWH | YPR | 21-Nov-15 |
12378 | NJP | SDAH | 20-Nov-15 |
52544 | DJ | KGN | 18-Nov-15 |
13149 | BWN | NJP | 15-Nov-15 |
12864 | KJM | HWH | 13-Nov-15 |
12864 | KJM | HWH | 10-Nov-15 |
12640 | KJM | MAS | 4-Nov-15 |
12840 | MAS | HWH | 4-Nov-15 |
12246 | YPR | HWH | 16-Aug-15 |
Things to remember;
1. R is case sensitive HWH & hwh are not the same
2. results from using filter is stored in KJM
3. for equal we use double ==
Comments
Post a Comment