Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • you are scripting tmp twice.. do you mean to use row instead inside the loop? Commented Aug 31, 2012 at 0:15
  • Where does your k come from? What shape is your tmp? Commented Aug 31, 2012 at 0:29
  • OK for this example, but this question may be extended to a multidimensional boolean array in which you want the index of 'True' values Commented Apr 1, 2016 at 9:05
  • 2
    That's some pretty obfuscated R code for "the number of previous elements which were < x[k+1]. We don't even need the inefficient length(which(...)), we only need to directly sum the Booleans sum(x[1:k] < x[k+1]). Commented Nov 27, 2016 at 17:34
  • Related question Pandas Equivalent of R's which() Commented Nov 27, 2016 at 17:35