Hi S,
I did try (briefly) to work out a way to use lapply but couldn't quite
get it right. After a bit of fooling around the following does work as
a standalone command:

lapply(subsets, function(sub, x)
do.call(subset,list(x,subset=eval(parse(text=sub)))), x=A)

Thanks for the improvement.

Jim


On Thu, Jan 29, 2015 at 10:32 PM, S Ellison <s.elli...@lgcgroup.com> wrote:
>
>
>> -----Original Message-----
>> subsets<-list(B="(A[,1] %in% c(1,2) & A[,2] %in% c(1,2)) | (A[,1] %in%
>> c(3) & A[,2] %in% c(1)) | (A[,1] %in% c(4) & A[,2] %in% c(1:4))",  C="(A[,1] 
>> %in%
>> c(1:4) & A[,2] %in% c(1,2))",  D="(A[,1] %in% c(1,2) & A[,2] %in% c(1:3)) | 
>> (A[,1]
>> %in% c(3) & A[,2] %in% c(1,2))")
>>
>> multi_subset<-function(x,sublist) {
>>  result_list<-list()
>>  for(sub in 1:length(sublist))
>>   
>> result_list[[sub]]<-do.call(subset,list(x,subset=eval(parse(text=sublist[[sub]]))))
>>  names(result_list)<-names(sublist)
>>  return(result_list)
>> }
>
>
> Or something like
> lapply(subsets, function(sub, x) 
> do.call(subset,list(x,subset=eval(parse(text=sublist[[sub]])))), x=x)
>
> ?
>
>
>
>
> *******************************************************************
> This email and any attachments are confidential. Any u...{{dropped:8}}

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to