Unit conversions return error message "could not find function "m_to_ft."

42 views Asked by At

The "measurements" package should be installed and loaded. My first unit conversion (copied below) worked just fine:

temp_f <- 100
temp_c <- F_to_C(temp_f) 
print(paste(temp_f, "ºF is equivalent to", temp_c, "ºC"))

However, the following conversion will not run:

dist_meters <- 100  
dist_feet <- m_to_ft(dist_meters)

I keep getting the error message:

"Error in m_to_ft(dist_m) : could not find function "m_to_ft""

As far as I can tell I'm writing the code correctly and the package seems to be installed and loaded correctly since it worked on the first conversion.

I have tried changing the capitalization (I had to do this with the first conversion before it ran correctly).

1

There are 1 answers

0
Yas On

I don't think measurements package has m_to_ft(), you can use conv_unit() which converts common units of measurements:

dist_m <- 100
dist_ft <- conv_unit(dist_m, "m", "ft")
print(paste(dist_m, "meters is equivalent to", dist_ft, "feet"))

output:

[1] "100 meters is equivalent to 328.083989501312 feet"