user2961410
user2961410

Reputation: 73

How do I find the length of a column ending at a specific value within the column?

How do I find the length of a column ending at a specific value within the column in R?

I have been stuck on this for hours please help!

Upvotes: 0

Views: 90

Answers (1)

Carl Witthoft
Carl Witthoft

Reputation: 21492

Your question is incomplete: for example, do you want the first instance of the specific value? if so, then

which( my_matrix[,my_column_number] == my_value) will return the index of the match, which happens to be the length to that point in the column. (Usual warnings about using == with floating-point data apply).

Upvotes: 1

Related Questions