Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exploring R and RStudio environment Exercise 1: a) Add two numbers (4 and 7), assign it to the variable addition and print it in a

Exploring R and RStudio environment
Exercise 1:
a) Add two numbers (4 and 7), assign it to the variable addition and print it in a one-line code.
b) Exponentiate the integer 2 to the power 2.5 and assign it to the variable Exp.
c) Assign the modulo of 25/7 to the variable Mod.
d) Assign the value 156 to the variable Drink, assign the value 211 to Sandwich, assign the value 36 to the variable Fruit. Add all these variables to one variable called Lunch_Calories. Print the total Calories consumed.
e) Define the variable My_logical as FALSE, check class of the variable.
f) Define the variable My_Uni as PSUT, check class of the variable.
Exercise 2:
You played a game of chance. The first game you start with certain number of points and you play certain number of rounds. After that you will end up with final total points. Suppose you played the game in the first week and you started with 100 points. After that you ended up each day either with extra points or you lost points. Then you changed to game 2 that have the same logic. You started again with 100 points but the probability of winning or losing is not the same as game 1. Which game is better to play?!
a) Define the variable My_Luck and assign to it the value Go!
b) Define a numeric vector My_numbers with the values (1,10,49).
c) Define a character vector My_char with the values (a, b, c).
d) Define a boolean vector My_Logic with the values (TRUE, FALSE, TRUE).
e) Define the variable My_Game1_Win with the values (140, -50, 20, -120, 240).
f) Define the variable My_Game2_Win with the values (-24, -50, 100, -350, 10).
g) Assign days as names of My_Game1_Win vector.
h) Assign days as names of My_Game2_Win vector.
i) Assign days of week names (Sunday, "Monday", "Tuesday", "Wednesday", "Thursday") to a vector called days_names.
j) Assign to total_daily how much you won/lost on each day.
k) Assign total_game1 to your total win/loss in your game 1.
l) Assign total_game 2 to your total win.loss in your game 2.
m) Find your overall winnings/losses and assign it to total_weeks.
n) Check if you realized higher total gains in game 1 than in game 2.
o) Assign the third element of the vector My_Game2_win to the variable Game2_Tuesday.
p) Assign the Game1 results of Monday, Tuesday, and Wednesday to the variable Game1_midweek.
q) Assign to Game2_selection_vector game2 results from Monday up to Thursday; make use of :
r) Fine the mean to Game2_selection_vector.
s) Which days you made positive gains (winnings) in game1? Assign the results to selection_vector. Then use selction_vector as to find winning days names and assign the results to Game1_winning_days.
Exercise 3:
Create a program that reads the entries to different values of calories intake and produce the total number of calories intake at the end. See the example below:
What is your name? Osama
How much calories your drink contains? 100
How much calories your Sandwich contains? 250
How much calories your fruit contains? 50
[1] "Hello, and Welcome to Calories Calculator! Osama Your calories consumption total is 400"

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions

Question

1. Who is responsible for resolving this dilemma?

Answered: 1 week ago

Question

7. How might you go about testing these assumptions?

Answered: 1 week ago