# convert centimeters if ( unit == "cm" ){ height <- height / 100 unit <- "m" # set all units to meter } # convert inches if (unit == "inch" ){ height <- height / 39.37 unit <- "m" # set all units to meter } # convert feet if (unit == "ft" ){ height <- height / 3.28 unit <- "m" # set all units to meter }