I currently wish to divide a data frame into subsets for training/testing. In the data frame there are columns that contain different items, and some contain sub-items like (Aisle01, Aisle02, etc.) I am getting tripped up by filtering out a partial string in multiple columns.
Data sample:
Column1 Column2 Column3
Wall01 Wall04 45.6
Wall04 Aisle02 65.7
Aisle06 Wall01 45.0
Aisle01 Wall01 33.3
Wall01 Wall04 21.1
If my data frame (x) contains two columns that within them contain multiple version of "Aisle", I wish to filter out everything from both columns that contains "Aisle". Wondering if the line below is somewhat on the right track?
filter(x, column1 & column2 == grep(x$column1 & x$column2, "Aisle"))
Desired result:
Column1 Column2 Column3
Wall04 Aisle02 65.7
Aisle06 Wall01 45.0
Aisle01 Wall01 33.3
Thank you in advance.