Help plz

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Help plz

hazem1
This post has NOT been accepted by the mailing list yet.
Hello everyone
I`m trying to solve this problem below
I would like to get your help
with thank

####################
 1)  Simulate a random vector a with 100 elements from the uniform distribution on the
interval (−5,5).

2) To calculate the sumof the negative integers in vector a

3) To calculate the sum of the vector elements until the first appearance of the first
negative element.
###################

Reply | Threaded
Open this post in threaded view
|

Re: Help plz

Pete Brecknock
Typing "?" (no quotes) followed by a topic of interest will throw up the R Help documentation.

1. Have a look at ?runif

2. Try ?subset and ?cumsum

3. Look at ?rle. Use in conjunction with cumsum and maybe ifelse.

HTH

Pete