RCPP - temporary variable : i wanna ask about temporary variable, in this code i want to replace the k-th row of Ynew1 by zero, and in every iteration the value of Ynew1 is updated by X (first value). but in my code not only row of Ynew1 are replace by 0, but the X too. and, unfortunately the result is Ynew1 is matrix all zero (i expected the result just last row has zero value). this is the code :


cppFunction('
            NumericMatrix cobo(NumericMatrix X){
            int n = X.nrow();
            NumericMatrix Ynew1(n,1);
            
            
            for (int k=0;k<n;k++){
              Ynew1 = X;
              for(int i=0;i<n;i++){
                    Ynew1(k,i)=0;
              }
            
            }


            return(Ynew1);
            }
            ')