Suppose I have a matrix, for instance m = matrix(c(1, 2, 3, 4, 5, 6), ncol = 3) and a vector v = c(3, 2). v is the index of element from each row to take, so the result would be c(5, 4). How to achieve this, keeping operations vectorized?
            Asked
            
        
        
            Active
            
        
            Viewed 45 times
        
    0
            
            
         
    
    
        enedil
        
- 1,605
- 4
- 18
- 34
- 
                    The third element in the first row is 5 and the second element in the second row is 4. How is (6,5) the desired result? What am I missing here? – MrFlick Dec 12 '19 at 19:45
- 
                    Please see the last answer here [link](https://stackoverflow.com/questions/14782206/how-do-i-change-a-single-value-in-a-data-frame/57463973#57463973). – Mohamed Rahouma Dec 12 '19 at 19:47
- 
                    @MohamedRahouma Did you link to the wrong answer? What you posted doesn't seem at all related to the question. There's no replacement happening here. – MrFlick Dec 12 '19 at 19:52
- 
                    @MrFlick you're right, I corrected example. Anyway, question solved. – enedil Dec 12 '19 at 20:14