Hi, I am trying to run a function on every column of a data frame.
example data frame:
df <- data.frame(a = c(1:5), b = c(6:10), c = c(11:15))
function name is char_to_num(column).
my first solution was to manually call it
df$a = char_to_num(df$a)
df$b = char_to_num(df$b)
df$c = char_to_num(df$c)
but this is not reasonable and if I have more columns it is unnecessary work.
my first thought was to do a for loop but the values are not changing
for (i in colnames(df)){
i = paste0("df$", i)
i <- char_to_int(i)
}
I know I am accessing the 'i' variable and not the actually data frame but I want to emulate my first solution and unsure how to grab address of the column.