r - Finding the index of a vector from another vector -


i have 3 vectors a, r , b. want check first element of r between 0 , first element of vector a , if yes put 0 vector b, if not , belong interval , extract value form vector b, ...how can in r?at end should have vector sample 20 , values belong vector b.

      =c(0.1531532, 0.2432432, 0.3243243, 0.3648649, 0.3873874, 0.4054054,         0.4594595, 0.5720721, 0.7522523, 1.0000000)       set.seed(2)       r = runif(20, 0, 1)       b = 0:9       result = c( 1, 8, 8, 1, 9, 9, 0, 9, 7, 7, 7, 1, 9, 1, 5, 9, 9, 1, 6, 0) 

r> = c(0, a) r> cut(r, a, labels = b)  [1] 1 8 8 1 9 9 0 9 7 7 7 1 9 1 5 9 9 1 6 0 levels: 0 1 2 3 4 5 6 7 8 9 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -