I'm trying to remove the space that at the start of each variable but not the spaces after that.
I have a list like this:
input= structure(list(X = 2:4, V1 = c(NA, NA, NA), V2 = c(" Tescho123C",
" Tescho123A", " Tescho123B"), V3 = c(" Instrument", " Instrument",
" Instrument"), V4 = c(" :Fanta", " :Fanta", " :Fanta"), V5 = c(" :Tool Time",
" :Tool Time", " :Tool Time")), class = "data.frame", row.names = c(NA,
-3L))
And I'm trying to get something like this
output = structure(list(X = 2:4, V1 = c(NA, NA, NA), V2 = c("Tescho123C",
"Tescho123A", "Tescho123B"), V3 = c("Instrument", "Instrument",
"Instrument"), V4 = c(":Fanta", ":Fanta", ":Fanta"), V5 = c(":Tool Time",
":Tool Time", ":Tool Time")), class = "data.frame", row.names = c(NA,
-3L))
Everything I've tried seems to be more complex than it should be and takes a long time to run.
NB: trimws does not work on list - only vectors - and I'd prefer for to have to change my input.
Can anyone suggest an elegant solution?