In R, I am trying to implement matrices as arguments in functions to return another matrix with the result being certain matrix elements modified.

In R, can you create a function 'double_odd' of which argument is an integer matrix x returning a matrix same size as x with all its odd numbers doubled.

A basic solution would be appreciated as it'd help me understand the language more, however, seeing a short version would be interesting to see as well.

Many thanks in advance.

New contributor
Mattex is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    \$\begingroup\$ Is this question really off-topic? The question is tagged as code-golf. \$\endgroup\$ – tsh Dec 2 at 9:29
  • 1
    \$\begingroup\$ I've edited the title, you can revert the edit if you preferred the original. You might be able to edit this into a good challenge. Try reading some other challenges first, to see how it should be formatted. \$\endgroup\$ – Redwolf Programs Dec 3 at 15:27

Browse other questions tagged or ask your own question.