The most simple and straight-forward approach is using parzer library. For example, given points
library(parzer)
latitude = "40°14'55.5"
lat_out = parse_lat(latitude)
longitude = "19°58'22.7"
lon_out = parse_lon(longitude)
Note: the direction is not required.
For more information, check https://semba-blog.netlify.app/02/25/2020/geographical-coordinates-conversion-made-easy-with-parzer-package-in-r/