Skip to content

how to rbind matrices from different loops

3 messages · Matt Spitzer, jim holtman

#
Is this close to what you want:
+ ( abs(round(rnorm(50,mean=500,sd=250),digits=0)))
+ ,3), group=rep(1:15,10))
+     , lapply(split(example, example$group), function(.grp){
+         data.frame(group = .grp$group[1L]
+                 , unique = paste(unique(.grp$id), collapse = ',')
+                 )
+         })
+ )
group                                   unique
1      1  175,186,226,318,458,609,633,682,719,869
2      2 290,361,408,487,500,559,773,779,809,1459
3      3 201,283,371,470,479,513,576,719,810,1037
4      4   4,18,118,212,291,482,738,818,1008,1095
5      5 115,243,253,385,396,447,547,625,790,1156
6      6  175,186,226,318,458,609,633,682,719,869
7      7 290,361,408,487,500,559,773,779,809,1459
8      8 201,283,371,470,479,513,576,719,810,1037
9      9   4,18,118,212,291,482,738,818,1008,1095
10    10 115,243,253,385,396,447,547,625,790,1156
11    11  175,186,226,318,458,609,633,682,719,869
12    12 290,361,408,487,500,559,773,779,809,1459
13    13 201,283,371,470,479,513,576,719,810,1037
14    14   4,18,118,212,291,482,738,818,1008,1095
15    15 115,243,253,385,396,447,547,625,790,1156
On Thu, Feb 16, 2012 at 11:15 AM, Matt Spitzer
<matthewjspitzer at gmail.com> wrote:

  
    
#
If you want a row for each unique item:
+ ( abs(round(rnorm(50,mean=500,sd=250),digits=0)))
+ ,3), group=rep(1:15,10))
+     , lapply(split(example, example$group), function(.grp){
+         data.frame(group = .grp$group[1L]
+                 , unique = unique(.grp$id)
+                 )
+         })
+ )
group unique
1.1      1     15
1.2      1    282
1.3      1    361
1.4      1    497
1.5      1    553
1.6      1    583
1.7      1    618
1.8      1    729
1.9      1    817
1.10     1    842
2.1      2    135
2.2      2    253
2.3      2    290
2.4      2    351
2.5      2    418
2.6      2    457
2.7      2    518
2.8      2    594
2.9      2    686
2.10     2    804
3.1      3    208
3.2      3    327
3.3      3    442
3.4      3    516
3.5      3    536

On Thu, Feb 16, 2012 at 11:15 AM, Matt Spitzer
<matthewjspitzer at gmail.com> wrote: