How do I find the maximum and minimum number of a data frame using lapply and sapply?

0

I can figure out the maximum and minimum value of a data frame like this:

question2 <- data.frame (Month = c("January", "February", "March", "April", "May", "June"),
 Day1 = c(0.73, 0.97, 0.63, 0.35, 0.81, 1.24),

                           Day2 = c(1.04, 0.84, 0.48, 0.57, 0.82, 1.40),

                           Day3 = c(0.74, 0.88, 1.41, 0.82, 0.88, 1.28),

                           Day4 = c(0.88, 0.65, 0.82, 0.45, 1.00, 1.38),

                           Day5 = c(0.80, 1.16, 0.84, 0.69, 1.60, 1.50))

using lapply and sapply? I do not want these values for each line and yes for the whole date frame. I know there are other ways to encront them but I need to use sapply and lapply to resolve the issue. I've only been able to solve it by creating a list of just days values (deleting the first column with the names). But still I did not get a single maximum value. Only the maximum and minimum value per column:

q2  <- list((Day 1 = c( 0.73...),
             Day 2 = c( 1.04...),
             Day 3 = c(0.74...),
             Day 4 = c(0.88...),
             Day 5 = c(0.80...))

lapply (q2,max)

sapply (q2,max)

lapply (q2,min)

sapply (q2,min)
    
asked by anonymous 26.04.2018 / 02:29

0 answers