Day 11: I got excited and made a boo-boo

Hey hey

I hope you had a pleasant weekend

No e-mails from me so that you can catch-up (which I hope you did 👀)

Today, we're going to learn a basic (but useful) concept before which I want to address one thing

If you're new (joined any day last week) and haven't received any of my last emails hit 'reply'. I want to help you get up to speed.

If you remember our last mail on Friday, we saw a new function

Yes... we spoke about 'pipes' but I snuck a new function in

You didn't notice?

tch tch ...

someone's not been paying attention



While learning to use pipes (or |>) we came across the 'filter' function

Now, the filter function, as you guessed it 'filters' what you need

Let's put this to the test :)

library(tidyverse)
library(nycflights13)

view(flights)

flights |>
    filter(dep_delay > 120)

Expected result: # A tibble: 9,723 × 19

flights |>
filter(month == 1 | month ==2)

Expected result: # A tibble: 51,955 × 19

Please note something special in R.

= doesn't work when you want to tell R month = 1

You'll have to use ==

What does '=' do? It acts as an assignment function, the same as <- (something we learned last week)

You can try the code above with = instead of == and let me know what error you get :)

But in a nutshell, this is a simple introduction to the filter function.

Remember - we're starting easy so understand the ability of the different functions for now (and I hope you're taking notes 👀)

Previous
Previous

Day 12: The worst thing people do in UNO

Next
Next

Day 10: What do Bob the builder and R have in common?