Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

Function that converts feet and inches to centimeters [duplicate]

$
0
0

This question already has an answer here:

I have a function that works on a df to convert observations with multiple different prefixes & formats to numeric:

sapply(df, function(x) {x<-gsub("'(\\d*)''",".\\1",x)
     as.numeric(gsub("[^[:digit:].-]","",x))})

The issue I am having is the function takes the input:

44'6"

And converts it to

446

Is there any way to keep the same function, but modify it to convert these specific types of observations to centimeters?

I am sorry I do not know how to provide a reproducible example, but here is a picture of how the df is setup

DF Example

Thank you


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>