I have one data frame and with 2 columns and 3 rows, and I want to get the min and max value of the second column, I can get that with min(data[,2])
, but my problem is, I have to increment the second column when the number requested is matched to the first column. Here comes the interesting part when i increment 2 different rows the max and min only compare to those two instead of all column.
The initial data frame is:
item freq
1: 4 1
2: 3 1
3: 1 1
The request are 3,3,4. And the data frame become like this:
item freq
1: 4 2
2: 3 3
3: 2 1
And I want to know the max and min and I get max=3 and min=2 and the min should be 1.