}
private static SEXP doApply(Context context, Environment rho, FunctionCall call, PairList args) {
EvalException.check(call.length() > 1, "argument \"EXPR\" is missing");
SEXP expr = context.evaluate(args.getElementAsSEXP(0),rho);
EvalException.check(expr.length() == 1, "EXPR must return a length 1 vector");
Iterable<PairList.Node> branches = Iterables.skip(args.nodes(), 1);
if(expr instanceof StringVector) {
String name = ((StringVector) expr).getElementAsString(0);
if(StringVector.isNA(name)) {
context.setInvisibleFlag();
return Null.INSTANCE;
}
SEXP partialMatch = null;
int partialMatchCount = 0;
for(PairList.Node node : branches) {
if(node.hasTag()) {
String branchName = node.getTag().getPrintName();
if(branchName.equals(name)) {