I want to save the matrix of values that the barplot()
command returns into a variable, but I don't want the plot window:
x <- 1:5
b <- barplot(x) # this opens a window with the barplot
I have seen the answers that suggest to create a new function from the barplot function or to send the graphic to a "NULL file", but I'm not happy with either of these options.
Isn't there a way to tell a plot function not to plot, but only return its values? In the same way that you can use type = "n"
to suppress the points and axes = FALSE
to suppress the axes.
I was also thinking of lm()
, which outputs the results, and lm0 <- lm()
, which doesn't. Here, assigning the function to a variable suppresses any output to the GUI.