I am building a gui which lets me select a subset of a data.frame by clicking on the various factor names.
After having received user input, how do i pass it to the subset function?
e.g.: I have a dataframe df with factors MORNING and EVENING in column timeofday and RECEIVE and SEND in column optype. From the GUI I know that the user wants to a subset containing only RECEIVE operations, so i have the following strings as well:
RequestedFactor1 which equals “optype”
RequestedRelationship1 equals “==”
RequestedValue1 which equals “RECEIVE”
What can i do to those strings to pass them to subset, so that I will receive the same output as if i had called subset(df,optype==”RECEIVE”) ?
TIA
For this you can use an eval-parse construct, but again I warn that this is actually tricky business. Please read the help files about these two very carefully. So in your case this becomes :
An example to illustrate some tricky parts :
Mind the escaped quote-marks (\”). This is necessary as you want to test against a string, and not the RECEIVE object. Alternatively you can do :