Use -
# install.packages("measurements")
library("measurements")
ft_inch <- function(str_ft_inch){
elem <- as.integer(unlist(strsplit(str_ft_inch, "'")))
inch <- elem[1]*12 + elem[2]
return(conv_unit(inch, "inch", "cm"))
}
df["cm"] <- sapply(df[,"height"], ft_inch)
Output
> df[,"cm"]
[1] 177.80 172.72 180.34 182.88 177.80 187.96 180.34 187.96 187.96 170.18
[11] 175.26 170.18 185.42 182.88 180.34 182.88 195.58 185.42 185.42 177.80
[21] 180.34 180.34 182.88 193.04 195.58 177.80 182.88 185.42 177.80 177.80
[31] 172.72 185.42 182.88 180.34 182.88 172.72 172.72 185.42 180.34 187.96
[41] 172.72 180.34 182.88 190.50 172.72 182.88 187.96
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…