Search code examples
rplothistogramminimum

How to plot the minimum value between 2 columns for each row in a matrix?


I have the following table:

[1,]    434    359
[2,]   8012   8217
[3,]   1254   1360
[4,]     39    112
[5,]   4322   4199
[6,]    595   2737
[7,]  12984  13112
[8,]   5597   4287

I want to plot a histogram of the smallest value from each row. I know the hist() function in R, but I don't know how to plot only the minimum value between the 2 columns.

Also, I tried installing ggplot2 but it didn't work, so that's not really an option for me.


Solution

  • ?pmin

    hist(pmin(x[,1], x[,2]))