Log max value + name

Hi, I have this data and I want to calculate the maximum value of the log of the variable 1 and see the name of the person how has this max value.

my_data <- tibble(Var_1 = c(900, 1500, 350, 1200, 750, 100,125,250,300),
                                  Name = c ("Mary", "Rebeca", "Lucia", "Albert", "Rick", "Melissa", "Elizabeth", "Oscar", "Silvia"),
                                  Gender = c("W", "W", "W", "M", "M", "W", "W", "M", "W"),
                                  my_weights = c(2.2, 3.1, 8.2, 4.2, 5.3, 6.8, 12, 25, 1)) %>% mutate(
                                    year=2017
                                  )

I use this function but I donĀ“t know how to see the name of the person with the log highest value

log(my_data$Var_1) %>%
  max()

Here is one way

my_data$mylog  <- log(my_data$Var_1) 

subset(my_data, my_data$mylog == max(mylog))

or in tidyverse style

my_data  %>%  mutate(mylog = log(Var_1))  %>% filter(mylog == max(mylog))

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.