[R] sequential input script dataframe process functionality

rl at openmailbox.org rl at openmailbox.org
Mon Sep 8 17:13:23 CEST 2014


On Mon, 8 Sep 2014 07:55:23 -0700
William Dunlap <wdunlap at tibco.com> wrote:

> Again, feed the output of menu() directly into "[".  Do not use
> switch(). Bill Dunlap

The function was changed to:

testdataextract1<-function (testdata) {
selectionresult<-menu(c(unique(levels(testdata[,1]))),graphics=FALSE,title='Select
something') return (testdata[selectionresult,])
}
testdataextract1(testdata)

> testdataextract1(testdata)
Select something

1: text test1
2: text test2
3: text test3

Selection: 2
    variablea   variableb variablec
2 text test2 other texty       200

However, how to adjust the function 'return' so that _all_ values that
match the selected value from the menu are returned (as below)?

>> 
>> Although the menu must show only unique values to be chosen, the
>> resultant output must show all values that match the chosen value in
>> this example:
>> 
>> text test2 other texty       200
>> text test2 other texty       700
>> text test2 other texty       300
>> text test2 other texty       250



More information about the R-help mailing list