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

Is there a function in Base R that convert fractions to doubles [duplicate]

$
0
0

I have a dataframe that includes both pure fractions, integers with fractions and pure integers. Is there a base R function that can convert these string values to doubles.

For example:

df <- c("1 1/4", "1/2", "12 3/4", "1")
df2 <- function(df)
df2

>>(1.25,0.5,12.75,1.0)

Or do I need to write a function for this?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



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