I have a R data frame.Let's say my data,df_sample looks like below
var1 var2 var3 var4
12 22 32 42
23 11 22 32
25 15 12 11
I want to write a function which will take data frame name & variable name,not the index as per requirement, as input & will print a title.
so I tried this
test <- function(data, var) {
Title=paste("Check for:",var)
message(Title)
}
test(df_sample,var1)
But I'm getting error message as
Error in paste("Check for:",var) object 'var1' not found
can you please help me to resolve this issue?