Skip to content
Prev 365831 / 398502 Next

Write a function that allows access to columns of a passed dataframe.

Hello,

You don't need xx <- deparse(substitute(...)), since you are passing the 
data.frame to your function. Just use


myfun <- function(frame,var){

   [...]

   # Nor does this work.
   col <- frame[,yy]
   print(col)
}

myfun(mydf,age)
myfun(frame = mydf, var = age)
[1] 2 3
I can get the name of the dataframe as a text string!
[1] "mydf"
I can get the name of the column as a text string!
[1] "age"
[1] 20 34 43 32 21


Hope this helps,

Rui Barradas



Em 05-12-2016 14:44, John Sorkin escreveu:

Thread (21 messages)

John Sorkin Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 5 John Sorkin Write a function that allows access to columns of a passed dataframe. Dec 5 Bert Gunter Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 5 David Winsemius Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 5 David Winsemius Write a function that allows access to columns of a passed dataframe. Dec 5 Bert Gunter Write a function that allows access to columns of a passed dataframe. Dec 5 Bert Gunter Write a function that allows access to columns of a passed dataframe. Dec 5 Bert Gunter Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 6 John Sorkin Write a function that allows access to columns of a passeddataframe. Dec 6 Rui Barradas Write a function that allows access to columns of a passeddataframe. Dec 6 William Dunlap Write a function that allows access to columns of a passeddataframe. Dec 6 Rui Barradas Write a function that allows access to columns of a passeddataframe. Dec 6 William Dunlap Write a function that allows access to columns of a passeddataframe. Dec 6 David Winsemius Write a function that allows access to columns of a passeddataframe. Dec 6 Bert Gunter Write a function that allows access to columns of a passeddataframe. Dec 6