Basic R-Software command questions (S.O.S)

#1
Hello. I just recently started to learn R, therefore, I am not very familiar with the commands. I will be more than grateful if someone explain how to input the following problems in R. I really want to learn to be good with this software. Thank you.




Bob asks Alice for lunch together. They agree to meet at the train station at noon.
Assume that they arrive at the station uniformly from 12:00 to 12:30 independently.
That is, they arrive at the station anytime from 12:00 to 12:30 with equal probability.
This assignment is to simulate this situation with number of simulation ns=1000. The
following steps will guide you to perform this simulation.

(a) Using the number 23700 as the random seed, generate ns=1000
random numbers from U(0,30) and save them to alice. This represent Alice’s
arrival time (0=12:00 and 30=12:30). Similarly generate ns=1000 random
numbers from U(0,30) and save them to bob. This represent Bob’s arrival time.

(b) They both agree that they will wait for each other for at most 10 minutes. For
example, if Alice arrive at the station 12:05, then she will leave if Bob doesn’t
show up on or before 12:15. Write R commands to compute the proportion that
they will meet (among these ns simulations).

(c) Suppose they agree to wait for each other for at most 5 minutes instead of 10
minutes. Write R commands to compute the proportion that they will meet.

(d) Write R command(s) to count how many times (out of these ns simulations) that
Alice arrives before Bob.

(e) Combine alice and bob to form a nsx2 matrix T with alice in the first column and
bob in the second column.

(f) Select all the rows in T correspond to the case that Alice arrives before Bob and
save them to AB. Similarly select all the rows in T correspond to the case that
Bob arrives before Alice or they arrive at the same time and save them to BA.
That is, the number of rows in AB plus the number of rows in BA should be ns.

(g) Suppose Alice will wait for Bob for only at most 5 minutes while Bob will wait
for Alice for at most 10 minutes. Write R commands to compute the proportion
that they will meet (among these ns simulations).

(h) Compute the probability of they will meet in part (b), (c) and (g) respectively.
 

Dason

Ambassador to the humans
#2
Hi! :welcome: We are glad that you posted here! This looks like a homework question though. Our homework help policy can be found here. We mainly just want to see what you have tried so far and that you have put some effort into the problem. I would also suggest checking out this thread for some guidelines on smart posting behavior that can help you get answers that are better much more quickly.

For coding issues I also suggest looking at this thread: http://www.talkstats.com/showthread.php/29338-How-to-use-Code-tags