# NOT RUN {
## default vector method
mpg <- mtcars$mpg
fmax(mpg) # maximum value
fmin(mpg) # minimum value (all examples below use fmax but apply to fmin)
fmax(mpg, TRA = "%") # Simple transformation: Take percentage of maximum value
fmax(mpg, mtcars$cyl) # Grouped maximum value
fmax(mpg, mtcars[c(2,8:9)]) # More groups...
g <- GRP(mtcars, ~ cyl + vs + am) # Precomputing groups gives more speed !!
fmax(mpg, g)
fmax(mpg, g, TRA = "%") # Groupwise percentage of maximum value
fmax(mpg, g, TRA = "replace") # Groupwise replace by maximum value
## data.frame method
fmax(mtcars)
fmax(mtcars, TRA = "%")
fmax(mtcars, g)
fmax(mtcars, g, use.g.names = FALSE) # No row-names generated
## matrix method
m <- qM(mtcars)
fmax(m)
fmax(m, TRA = "%")
fmax(m, g) # etc...
## method for grouped tibbles - for use with dplyr
library(dplyr)
mtcars %>% group_by(cyl,vs,am) %>% fmax
mtcars %>% group_by(cyl,vs,am) %>% fmax("%")
mtcars %>% group_by(cyl,vs,am) %>% select(mpg) %>% fmax
# }
Run the code above in your browser using DataLab