Question: Problem 2. Write the corresponding R code for each of the following questions. (a) Assign the value 15 to a variable x and create a

 Problem 2. Write the corresponding R code for each of the

Problem 2. Write the corresponding R code for each of the following questions. (a) Assign the value 15 to a variable x and create a vector y with the values (1, 2, 3, 10, 100). Multiply those vectors component-wise and save the result in an object . Calculate the sum of all elements in . (b) Generate a sequence from 0 to 10 and a sequence from 5 to 5. (c) Generate a sequence from 3 to 3 by 0.1 steps. (d) Define two vectors with the following data: t includes the strings "mon", "tue", "wed", "hu", "fri", "sat", and m includes (90, 80, 50, 20, 5, 20). Concatenate both vectors column-wise into a matrix with 5 rows and 2 columns and save this a a new object named study, (e) Create the following data frame: age sex height weight 21 m 18169 35 f 173 58 829m 17175 2 e 166 60 Calculate the minimum and maximum value in the column age. Obviously, there have been some issues collecting the data. Generate a variable selection that contains the result to the logical query of age under 20 and above 80. Use this variable to set the age observations to NA if age is under 20 or above 80. Calculate the Body Mass Index (BMI) BMI = Weight in kg Length in m of all people from the previous data frame. Store the results in a variable BMI and append it to your data frame. Round the resulting values

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!