find value which occurred more times in a group from data frame column R I have a data frame with latitude and longitude of a particular place. one place can have multiple lat, longs and those lat, long values can be same or different. I need to find the correct lat, long based on no.of occurances of lat, long for particular place.
example input data frame
df:

place    lat      long
hsy      7.343    32.849
hsy      7.343    32.122
hsy      7.567    31.567
hsy      6.934    32.122
bls      2.67     6.2
bls      3.345    5.9
bls      2.987    6.321
bls      2.987    4.56
bls      1.876    6.321
bls      2.987    6.321

expected output data frame
    place    lat      long
    hsy      7.343    32.122
    bls      2.987    6.321

expected output for lat is which ever value is occurred more times among its values for particular place and the output for 'long' column value also which ever value is occurred more times among its values for particular place.
tried below code using across, but across is not working. getting Error: 'across' is not an exported object from 'namespace:dplyr' or could not find function &quot;across&quot; error. any alternative for across function?
df %&gt;%
  group_by(place) %&gt;%
  summarise(across(c(lat, long),~names(sort(table(.x), decreasing = TRUE))[1]))
I think below code may help you.
df &lt;-data.frame(place=c('hsy','hsy','hsy','hsy','bls','bls','bls','bls','bls','bls'),
                lat = c(7.343,7.343,7.567,6.934,2.67,3.345,2.987,2.987,1.876,2.987),
                long=c(32.849,32.122,31.567,32.122,6.2,5.9,6.321,4.56,6.321,6.321) )

library(dplyr)

Mode function which will fetch number which has highest frequency
mode_fun&lt;-function(x){
  tbl=table(x)
  tbl=sort(tbl,decreasing = T)
  return(as.numeric(names(tbl[1])))
}

df1  = df %&gt;% group_by(place) %&gt;% summarise(lat1=mode_fun(lat),long1=mode_fun(long))