Back
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.
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))>
apply(matrix(1:10), 1, as.numeric)
[1] 1 2 3 4 5 6 7 8 9 10
invisible(apply(matrix(1:10), 1, as.numeric))
>
1.2k questions
2.7k answers
501 comments
693 users