Program R
I want to create a function in R which would take the column names from a data frame and create a new function which argument names are the same as the column names, having as many arguments as there are columns.
my_function<-function(data_frame){
return(new_function<-function(#column_name_1,#column_name_2,#column_name3,#column_name_x){
[function does something cool]
}
)
}
For example, if I have a data frame:
> dimorphandra
genus_species temp germinability waterpotential
1 Dimorphandra_mollis 30.8 86 0.0
2 Dimorphandra_mollis 32.5 94 0.0
3 Dimorphandra_mollis 35.0 74 0.0
4 Dimorphandra_mollis 37.0 44 0.0
5 Dimorphandra_mollis 39.0 2 0.0
6 Dimorphandra_mollis 41.0 0 0.0
Then I would apply my_function to it:
my_function(dimorphandra)
Which would output:
new_function<-function(genus_species,temp,germinability,water potential){
[function does something cool]
}
How can I create my_function?
Thank you very much!