Expressions and variables basic variables (solution)

Exercise

Here is a small program that converts a mass in kilograms to a mass in grams and then prints out the resulting value.

mass_kg <- 2.62
mass_g <- mass_kg * 1000
mass_g

Create similar code to convert a mass in pounds to a mass kilograms.

  • Create a variable to store a body mass in pounds. Assign this variable a value of 3.5 (an appropriate mass for a Sylvilagus audubonii).
  • Convert the variable from body mass in pounds to body mass in kilograms (by dividing it by 2.2046), and assign it to a new variable.
  • Print the value of the new variable to the screen.
Output solution
[1] 1.58759