6 Final Exercise
6.1 Final Exercise
Using pipes, modify the df_wq
data frame as so:
assign it to a new object named
df_new
filter
Date
to 2021 data onlyselect only the
Station
,Date
,Chla
, andPheophytin
columnsmutate
Station
in-place so it’s a factor column
Challenge:
Modify the df_new
data frame as so:
-
mutate
Chla
so it’s +20 specifically for the case when the month is April and the station is P8- Hint: April is the 4th month
-
assign it to the object
df_new
(ie. the same name)- can you access the “original”
df_new
now? what happens if you re-run the code?
- can you access the “original”
Code
df_new <- df_new %>%
mutate(
Chla = case_when(
month(Date) == 04 & Station == 'P8' ~ Chla + 20,
TRUE ~ Chla
)
)
df_new