Multidimension Vector Return Type of User-Functions?

For user specified functions, the parser in R-studio returns an error when attempting to return a M x N vector (base-type mismatch). e.g.:

vector function_A (vector input_A, vector input_B){ // input_A and input_B are 4x1 vectors
   vector[4] output[2]; // two 4x1 vectors
   output[1] = input_A;
   output[2] = input_B;

   return output;

Should I just use a MxN matrix type then?

[EDIT] forgot to ask, “why is that?”

Thank you for your time,

1 Like

Okay, I just found out declaring it:

vector[M] vect_A[N]

makes it an array of vectors instead of a vector. (


1 Like