r - How to select indices that end with a certain number? -


i have following vector:

x = c(31, 56, 78, 98, 76, 88, 90) 

and select values end in same number. example, 78, 88, 98.

you can use :

v <- c(31,56,78,98,76,88,90) v[v %% 10 == 8] # [1] 78 98 88 

note v %% 10 give mod of division of v 10.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -