Hi there,
I have a dataframe of character modes and I'm trying to turn them all into numeric. However, I keep getting this error:
Error: Problem with `mutate()` input `..1`.
x Can't subset columns that don't exist.
x Columns `5.42`, `5.01`, `4.73`, `4.52`, `4.24`, etc. don't exist.
i Input `..1` is `(function (.cols = everything(), .fns = NULL, ..., .names = NULL) ...`.
I have a dataset where I remove the first row because it contains units. I then use the mutate(across())
function to transform them the columns into numeric modes with the following code:
dt <- dt[-1,]
dt <- dt %>% mutate(across(.cols = dt$Green.Algae:dt$Temp..Sample, as.numeric))
That's when I get the error. Can anyone help me? Here's a subset of my data:
dt <- structure(list(Date.Time = c("date", "6/11/2021 8:16", "6/11/2021 8:16",
"6/11/2021 8:16", "6/11/2021 8:16", "6/11/2021 8:17"), Green.Algae = c("µg/l",
"5.42", "5.01", "4.73", "4.52", "4.24"), Bluegreen = c("µg/l",
"0", "0", "0", "0", "0"), Diatoms = c("µg/l", "12.79", "13.7",
"13.68", "13.14", "12.87"), Cryptophyta = c("µg/l", "0", "0",
"0", "0", "0"), Yellow.substances = c("r.u.", "2.09", "2.42",
"2.4", "2.47", "2.48"), Total.conc. = c("µg/l", "18.21", "18.71",
"18.41", "17.67", "17.11"), Transmission = c("%", "96.17", "96.3",
"96.48", "96.47", "96.4"), Depth = c("m", "2.05", "2.61", "3.21",
"3.78", "4.29"), Temp..Sample = c("¡C", "19.68", "19.18", "18.77",
"18.52", "18.25")), row.names = c(NA, 6L), class = "data.frame")
Thanks so much!!