Aan de slagGa gratis aan de slag

I %like% data.tables

%like% is a very useful function to filter rows from data.tables that match a pattern, as opposed to exact matches as seen in the previous exercise. It can be used independently on a vector as well, for example:

x <- c("aaba", "aaba", "baca")

# Search for "aa" anywhere in the string
x %like% "aa"
[1]  TRUE  TRUE FALSE

# Search for "ba" at the end of a string
x %like% "ba$"
[1]  TRUE  TRUE FALSE

The metacharacter $ indicates that you are searching for the string that ends with a specific pattern.

Deze oefening maakt deel uit van de cursus

Data Manipulation with data.table in R

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Filter all rows where end_station contains "Market"
any_markets <- batrips[___]
any_markets
Code bewerken en uitvoeren