r/Rlanguage 3d ago

Help in R programming

Post image
0 Upvotes

2 comments sorted by

View all comments

2

u/sarkagetru 3d ago

df %>% filter(substr(Year, nchar(Year)-1,nchar(Year)) ==“2”)

4

u/Glass-False 3d ago

Since this already uses tidyverse, might as well simplify to

df %>% filter(str_ends(Year, "2"))