Why doesn't this code change actually change the column names of TEST?
TEST = data.frame(col1 = LETTERS, col2 = letters)
"TEST" %>% paste0(" %<>% dplyr::rename(capitalLetters = 'col1') ") %>% parse(text = .) %>% eval()
I want to do a series of transforms to a large number of dataframes, where I have a list of the names of the dataframe environmental variable names. But I don't want to manually type out the transform for each dataframe, so I thought to use parse text -> eval.
EDIT: getting rid of the assignment pipe
"TEST" %>%
paste0(
., " <- ", .,
" %>% dplyr::rename(capitalLetters = col1) "
) %>% parse(text = .) %>% eval()
EDIT: Just noticed this doesn't work either
"A <- 3" %>% parse(text = .) %>% eval()
A
Error: object 'A' not found
I guess one cannot assign/update environmental variables through parse->eval?