If you look up lonsex2dec in the vmbase package (https://rdrr.io/cran/vmsbase/src/R/lonsex2dec.R) it doesn't look like that function vectorizes the sexagesimal to decimal operation.
Taking a tidyverse crack at it;
library(dplyr)
temp <- data.frame(stringsAsFactors=FALSE,
Direction = c("E", "E", "W"),
Degree = c(9, 144, 0),
Minute = c(13, 14, 2),
Second = c(49, 36, 45)
)
lonsex2dec <- function(degree, minute, second, direction) {
declon = if_else(
condition = (direction == "E"),
true = (degree + (minute / 60) + (second / 3600)),
false = -(degree + (minute / 60) + (second / 3600))
)
return(declon)
}
temp <- temp %>%
mutate(
decimal = lonsex2dec(
Degree,Minute,Second,Direction
)
)
temp
#> Direction Degree Minute Second decimal
#> 1 E 9 13 49 9.23027778
#> 2 E 144 14 36 144.24333333
#> 3 W 0 2 45 -0.04583333
Created on 2019-09-16 by the reprex package (v0.2.1)
Not totally sure that's how you are supposed to handle the direction argument. Online discussions (https://physics.stackexchange.com/questions/434569/convert-sexagesimal-to-decimal) ignore direction completely. But I'll take their word for it.