Suppress one command's output in R
I'm looking to suppress the output of one command (in this case, the apply function).
Is it possible to do this without using sink()? I've found the described solution below but would like to do this in one line if possible. How R suppress output?
To suppress the output of any command, apart from the sink() function, you can use the invisible() function as follows:
apply(matrix(1:10), 1, as.numeric)
[1] 1 2 3 4 5 6 7 8 9 10invisible(apply(matrix(1:10), 1, as.numeric))
>
This way you can surpass output in R.