0

I have a problem with split command in R...

I have this:

>x1
    $`1`
      [1] 130 165 150 150 140 198 220 215 225 190 170 160 150 225  95  97  85  90 215 200
     [21] 210 193  90  90 100 105 100  88 100 165 175 153 150 180 170 175 110  72 100  88
     [41]  86  70  80  90  86 165 175 150 153 150 208 155 160 190 150 130 140 150  86  80
     [61] 175 150 145 137 150 198 150 158 150 215 225 175 105 100 100  88  95 150 167 170
     [81] 180 100  72  85 107 145 230 150 180  95  95 100 100  80  75 100 110 105 140 150
    [101] 150 140 150  75  95 105  72  72 170 145 150 148 110 105 110  95 110 110 129  83
    [121] 100  78  97  90  92  79 140 150 120 152 100 105  81  90  52  60 100  78 110  95
    [141]  72 150 180 145 130 150  80  96 145 110 145 130 110 105 100  98 180 170 190 149
    [161]  88  89  63  83  66 110 140 139 105  95  85  88 100  90 105  85 110 120 145 165
    [181] 139 140  68  75 105  85 115  85  88  90 110 130 129 138 135 155 142 125 150  80
    [201]  80 125  90  70  70  90 115 115  90  70  90  88  90  90 105  80  84  84  92 110
    [221]  84  64  63  65  65 110 105  88  85  88  88  88  85  84  90  92  95  63  70 110
    [241]  85  92 112  84  90  86  84  79  82

$`2`
 [1]  46  87  90  95 113  90  70  76  60  54 112  76  87  69  46  90  49  75  91 112
[21] 110  83  67  78  75  75  67  71  70  95  88  98 115  86  81  83  70  71 102  88
[41] 120  58  78  78 110  48 103 125 115 133  71  71  77  71  69  76  78  48  48  67
[61]  67 110  62  88  74  75  80  76  74  52

$`3`
 [1]  95  88  88  95  65  69  95  97  92  97  88  88  94  90 122  67  65  52  61  97
[21]  93  75  96  97  53  53  70  75 108  68  70  75  67  97 110  52  70  60  95  97
[41]  95  97  68  65  65  60  65  90  75  92  75  65  65  67  67 132 100  72  58  60
[61]  67  65  62  68  75  75 100  74 116 120  68  68  88  75  70  67  67  67  96

Then just leave the first part which is what interests me:

>y1=x1[1]
    $`1`
      [1] 130 165 150 150 140 198 220 215 225 190 170 160 150 225  95  97  85  90 215 200
     [21] 210 193  90  90 100 105 100  88 100 165 175 153 150 180 170 175 110  72 100  88
     [41]  86  70  80  90  86 165 175 150 153 150 208 155 160 190 150 130 140 150  86  80
     [61] 175 150 145 137 150 198 150 158 150 215 225 175 105 100 100  88  95 150 167 170
     [81] 180 100  72  85 107 145 230 150 180  95  95 100 100  80  75 100 110 105 140 150
    [101] 150 140 150  75  95 105  72  72 170 145 150 148 110 105 110  95 110 110 129  83
    [121] 100  78  97  90  92  79 140 150 120 152 100 105  81  90  52  60 100  78 110  95
    [141]  72 150 180 145 130 150  80  96 145 110 145 130 110 105 100  98 180 170 190 149
    [161]  88  89  63  83  66 110 140 139 105  95  85  88 100  90 105  85 110 120 145 165
    [181] 139 140  68  75 105  85 115  85  88  90 110 130 129 138 135 155 142 125 150  80
    [201]  80 125  90  70  70  90 115 115  90  70  90  88  90  90 105  80  84  84  92 110
    [221]  84  64  63  65  65 110 105  88  85  88  88  88  85  84  90  92  95  63  70 110
    [241]  85  92 112  84  90  86  84  79  82

Realize then the same thing for the other variable:

> y2=x2[1]
$`1`
  [1] 12.0 11.5 11.0 12.0 10.5 10.0  9.0  8.5 10.0  8.5 10.0  8.0  9.5 10.0 15.5 15.5
 [17] 16.0 15.0 14.0 15.0 13.5 18.5 15.5 19.0 13.0 15.5 15.5 15.5 15.5 12.0 11.5 13.5
 [33] 13.0 11.5 12.0 12.0 13.5 19.0 15.0 14.5 14.0 20.5 17.0 19.5 16.5 12.0 12.0 13.5
 [49] 13.0 11.5 11.0 13.5 13.5 12.5 12.5 14.0 16.0 14.0 16.0 15.0 13.0 11.5 13.0 14.5
 [65] 12.5 11.5 12.0 13.0 14.5 11.0 11.0 11.0 16.5 18.0 16.0 16.5 16.0 14.0 12.5 13.0
 [81] 12.5 15.0 19.5 18.5 14.0 13.0  9.5 11.0 11.0 16.5 17.0 16.0 17.0 16.5 17.0 17.0
 [97] 18.0 16.5 14.0 14.5 13.5 16.0 15.5 14.5 16.0 16.0 21.0 19.5 11.5 14.0 14.5 13.5
[113] 21.0 18.5 19.0 19.0 15.0 13.5 12.0 17.0 16.0 18.5 14.5 17.0 14.9 17.7 13.0 13.0
[129] 13.9 12.8 15.4 14.5 17.6 17.6 22.2 22.1 17.7 21.0 16.2 17.8 13.6 13.2 12.1 12.0
[145] 15.0 14.0 14.8 15.5 12.5 19.0 13.7 14.9 16.4 16.9 17.7 19.0 11.1 11.4 12.2 14.5
[161] 16.0 15.8 17.0 15.9 14.4 15.5 13.2 12.8 19.2 18.2 15.8 15.4 17.2 17.2 15.8 16.7
[177] 18.7 15.1 13.2 13.4 11.2 13.7 16.5 14.5 16.7 17.6 15.4 18.2 17.3 18.2 16.6 15.4
[193] 13.4 13.2 15.2 14.9 14.3 15.0 13.0 14.4 15.0 17.4 22.2 13.2 14.9 16.0 11.3 12.9
[209] 13.2 15.5 16.5 18.1 20.1 18.7 14.4 14.3 15.7 16.4 14.4 12.6 12.9 16.4 14.9 16.2
[225] 20.7 15.8 19.0 17.1 16.6 19.6 18.6 18.0 16.2 16.0 18.0 16.4 20.5 14.7 17.3 16.4
[241] 17.0 14.5 14.7 13.0 17.3 15.6 11.6 18.6 19.4

But now I want to relate two variables, that is, perform again split with the 2 generated variables: y1 and y2

Then I use the split command (split(y2,y1)) again but throws me the following error:

Warning message:
In split.default(y1, y2) : data length is not a multiple of split variable

Can you help me?

By the way, the data is ordered well, for example, the first data y1 is related to the first data y2 and in the same way for the next.

lmo
  • 37,904
  • 9
  • 56
  • 69
Jac
  • 101
  • 2
  • 9
  • It's not clear what you're trying to achieve. What is the expected output? – Minnow Oct 24 '15 at 01:26
  • 1
    Could you please provide `x1` and `x2` using `dput`, as [explained here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – cocquemas Oct 24 '15 at 01:26

0 Answers0