Reading Questions - R Intro

Reading Questions Answer Checker

To check your answers put them in the appropriate box and click the 'Check' button. Every checker box can do arithmetic and calculate standard functions (see calculator help). If you give decimal answers, give them to at least 3 decimal places.

As you work you should have pencil and paper handy for calculations and thinking!

Note: some questions ask for a formula. For the checker we ask you to plug a value into the formula. For your pset you still need to give the whole formula.

Calculator

 =


 

 

At this point you should have installed R and R studio. If not, you should do that now.

 

The first thing to do with R is to make sure you can start it and then we will do some simple calculations. Give your answers to at least 2 decimal places of accuracy. Go ahead and start R Studio. You should see a window with 4 panes. The command prompt (the >) is in the bottom left window.

 

Problem 1. 

At the command prompt type the command

>  2 + 3

Hit return and enter the result here.

 


Problem 2. 

Do the following computations using R.
(Enter your answers in the boxes.)

>  2*3
 

>  2^3
 

>  3.14^3.14
 


Problem 3. 

Use R to do the following computation.
(Enter your answer to 2 decimal places in the box.)

>  100*mean(sin(30:87))
 


Problem 4. 

Now we'll do our first random simulation. Don't worry if you don't fully understand the commands. We will explain them in the first tutorial.

In order to simulate counting the number of heads in 1000 tosses of a fair coin give the following sequence of commands.

(Hit return after each one).

>  x = rbinom(1000,1,.5)
>  total = sum(x)

You can use the up arrow to go back and run the commands again. You should get a different total.

Give the value of the total number of heads for one of your simulations.