dataframe - R: return pmin or pmax of data.frame with multiple columns -
Is there any way to select pmax / pmin of data frame with multiple columns ??
I want to return only the maximum or the minimum, not the entire line.
  Max < - tail (df, n = 1) Maximum # v1 v2 v3 v4 v5 v6 v7 v8 # 2014-10 -03 17:35:00 58.91 45.81 33.06 70.76 36.3 9 45.53 33.52 34.36 a.m. (maximum) # v1 v2 v3 v4 v5 v6 V7 v8 # 2014-10-03 17:35:00 58.91 45.81 33.06 70.76 36.3 9 45.53 33.52 34.36    For this line, I expect a return value:  
  70.76    ... because it is the maximum value in all the columns.   
 
  Use  do.call  to call  Pmax  To compare all the columns for each line value, for example:    dat < - data.frame (a = 1: 5, b = delegate (3,5)) # abb # 1 1 3 # 2 2 3 # 3 3 # 4 4 3 # 5 5 3 Q. Call (bmx, dat) # [1] 3 3 3 4 5    When you call  pmax  directly on a complete data frame, then there is only one argument PA Ssed for the ceremony and nothing to compare it. Therefore, it argues for supply because it should be maximum. It works for non-numerical and numerical arguments, even if it does not matter:    pmax (7) # [1] 7 pmax ("a") # [1 ] "A" Pmax (using data.frame (1,2,3)) # X1 X2 X3 # 1 1 2 3    Using  do.call (pmax,. ..)  with data. Frame means that you can pass each column of data. As the list of logic for the frame to  pmax :    do.call (pmax) , Dat)    is equal to:  
  pmax (dat $ a, dat $ b)    
 
  
Comments
Post a Comment