I have a data-set with following column names:
> colnames(newdat1)
[1] "i4" "i2" "i3" "i1" "b4" "b3" "b2" "b1"
I also have a variable "newDV" which will always be the column name of the dependent variable if newdat1
> newDV
[1] "i1"
How can I get the column in newdat1 that corresponds to whatever newDV is? The idea being I don't want to have to manually type the item newDV corresponds to, such as newdat1$i1
in this case. I have tried the following
> gettheDV<-paste("newdat1",newDV,sep="$",collapse="")
> gettheDV
[1] "newdat1$i1"
I am not sure if this is on the right track, but any help would be appreciated. Thank you!