nikhil abhyankar
2011-Jan-07 12:21 UTC
[R] Extracting user specified variables from data frame to use as function arguments
Hello All; I am writing an R program in the form of a function to find out the summary statistics for response variable(s) in a data frame. I need to accept variable names from the data as arguments and use them inside the function for various tasks. The dataset name is also one of the arguments to the program. The tasks include merging two datasets, transposing a dataset or finding the summary stats of response variable(s) using the input variables as the 'by' variables. The variables specified as argument for the function are taken to be character strings and I have not been able to use these to extract the corresponding variables. As an example, suppose I have an argument 'merge_by' which is used to specify the variables used to merge two datasets. Typically, the input is "an period" (with the double quotes) but could be more or less variables than that. How do I input the user specified variables and use them for tasks like merging, transposing etc.? A similar problem is with specifying the user defined by variables in summaryBy. I have played around with substitute, parse, eval etc. but without success. Any suggestions? Thanks [[alternative HTML version deleted]]
Reasonably Related Threads
- read.csv converts "NA" to missing values
- Using summaryBy with weighted data
- summaryBy: transformed variable on RHS of formula?
- Aggregating a data frame (was: Re: new R-user needs help)
- Problem mit summaryBy: Group sums gives me "incorrectly" zero for one variable