I would like to be able temporarily assign the columns of a data.frame to variable names within a function.
mydata <- data.frame(a1="hello",a2=2,a3=3)
f <- function(mydata) {
for (i in names(mydata)) assign(i, tempdata[i])
print(a1)
print(a2+a3)
}
[1] "hello"
[2] 5
Thanks, I know this is another weird question but it would be helpful.