V <- c(1,3,2,4,2,3,1);
X <- 3;
pos <-V[V == X];
pos is 3 3.
what I need is the positions of all 3;
I need 2 and 6; which are the positions of 3 in V.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
whichNot what you’re asking for, but useful anyway: you can also use
which.minandwhich.maxto find the position of the minimum and maximum value of the array.