I have a data frame (df) with two columns named: Peter_Smith and Peter_Dow
df <- as_data_frame(matrix(ncol=2, nrow=2))
namesDF <- c("Peter_Smith", "Peter_Dow" )
names(df) <- namesDF
I want to get, for example, first column using:
library('dplyr')
target <- "Smith"
df1 <- select(df, eval(parse(text=paste0('Peter_', target)))
And get the next ERROR:
Error in eval(parse(text = paste0("Peter_", target))) :
object 'Peter_Smith' not found
Why?
I use R version 3.5.3 (2019-03-11) -- "Great Truth"