'Filter date as character

Im trying to filter a new frame by the date. But my dtf shows the "date" variable as character. This is what I have when run str function:

str(banco_4$dt_inic_tr)

Console shows: **chr [1:505057] "07 May 15" "26 May 15" "05 Sep 16" "21 Aug 15" "29 Apr 16"** ...

What I want to do is : filter the variable dt_inic_tr between "01 Jan 15" to "31 Dec 20".

banco_5 <-banco_4%>% 
filter((as.character(dt_inic_tr)>=as.character("01 Jan 15"))&
            (as.character(dt_inic_tr)<=as.character("31 Dec 20")))


Solution 1:[1]

Maybe it might be easier to transform the dates, e.g.

as.Date("01 Jan 15",format="%d %B %y")

This yields

"2015-01-01"

which makes the filtering a bit easier.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stephaela