I have a data frame here like this:
| segment_order | insight_group | index | 
|---|---|---|
| 1 | male | "1.25" | 
| 2 | female | "3.25" | 
| 3 | family | "5.25 | 
I wish to convert the data type of the index column is char data type. This is pretty easy to do with the as.numeric(as.character())
However because I would have to write this same line of code 10+ times I'm trying to write a function that intakes the dataframe and then mutates the column type from char to numeric. After multiple tries, I have tried
indexvariable.cleanup <- function(df){
  
  mutate(across(ends_with("_index")),as.numeric)
  )
  #return(data.frame(df))
}
But the [2] has to be an input. Other times I tried to intake two variables into the function, the dataframe and vect but the output would be a new column onto the dataframe which I do not want.