Hi Carrie,
You may have a problem with this if some subsets are empty:

L3<-lapply(split(df,cut(df$max,seq(0,1,by=0.01))),
 split,cut(df$submax,seq(0,0.2,by=0.02)))

Jim

On Thu, Jun 1, 2017 at 12:48 PM, carrie wang via R-help
<r-help@r-project.org> wrote:
>
> Hello,
> I want to split the dataframe into 1000 groups based on two column values(max 
> value and second max value). First, I made two lists L1 and L2.  L1 is the 
> list divided into 100 groups based on the range of max value and L2 is 
> divided into 10 groups based on the second max values. Now I want to do the 
> combinations based on L1 and L2. I want to do a for loop for L1 and for each 
> element in L1, I split it into 10 groups based on L2. I tried to write the 
> code, but it does not work.
>
> L1<-split(df,cut(df$max,seq(0,1,by=0.01)))L2<-split(df,cut(df$submax,seq(0,0.2,by=0.02)))
> Z<-list()G<-list()for (i in length(L1)){  Z=data.frame(L1[i])  G <- 
> split(Z$submax,"0.02")  print(G)  }
> Thanks so much!Carrie
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.

______________________________________________
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