Question: How to do the following or type it in R studio. Thanks in advance! 1 ) Write an R script to practice the if -

How to do the following or type it in R studio. Thanks in advance!
1) Write an R script to practice the if-else command, for two
alternatives. For alternative 1 compute the sum of 1,3, and 5. For
alternative 2 compute the product of 2 and 4. Define the alternative
by choosing the value of variable X at the beginning of the code,
and check X by using if to decide which alternative to compute.
2) Write an R script to practice the while command. Use a while
loop, which prints the elements of the sequence 2,4,6,...,20. Use
the start value 2, and increment the index by 2 in the loop.

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!