mardi 30 décembre 2014

Referencing a function parameter in R


Vote count:

0




I'm working on a function and need to know how to reference the incoming parameters.


For example, in python or lots of other languages, you can reference the input parameters something like this:



sys.argv[1:].


How can I reference the name of a parameter in R?


The specific problem I'm trying to solve is I want to capture the string value of the incoming parameter, so I can paste it as a concentration with a list of column_names I want to iterate through.


Here's the head of the function call, just so you can see the incoming parameter:



function(df_in)


So here's an example of the code I am writing and I want the string value of the dataframe_in, not the object that it references.



col_name <-paste(df_in,varnames[i],sep="$")


if df_in contained "my_df" and the current column_name is my_col, I'm trying to have col_name in the example above set to my_df$my_col.


I was thinking of using the get() function but quite sure how to apply it in this situation.


Thanks



asked 1 min ago







Referencing a function parameter in R

Aucun commentaire:

Enregistrer un commentaire