 <p>It is not possible, to return a vector <code>c(4, 'not possible', 3, 'not possible')</code> as such a vector does not exist. All elements in a vector must be of the same type. Off course you can output numbers an texts together. This is a simple exercise that can be solved in a number of ways. For teaching purposes, I propose the following, where the two problems are divided into two functions in a very functional manner:</p> <pre><code>getSingleRoot &lt;- function(x){ if(x&lt;0){ cat("not possible ") return(NaN) } else{ cat(sqrt(x)) cat(" ") return(sqrt(x)) } } getRoot &lt;- Vectorize(getSingleRoot) a &lt;- getRoot(c(4, -4, 9, -16)) </code></pre> <p>Other good solutions could make use of a <code>for</code> Loop, of <code>Map</code>, of <code>ifelse</code> or <code>sapply</code>, on <code>sqrt</code>already being a vectorized function and so on. Ìf this is homework, it depends on what you have already learned.</p>