Meenu Sahi
2009-Aug-06 20:02 UTC
[R] Write the results of sample function which uses a dataframe into an Array
Dear All? Basically I want to write the results of the sample function into an array is a specific order. The sample function uses a dataframe x.1 and therefore the result is also a dataframe and so I cannot write the result into the array in the correct order. If I convert x.1 into a matrix then the sample function fails. PLease help as to what is the problem !!! Has anyone had a similar problem? Please read the question and the problem in the attachment. Many thanks for your time. Kind regards Meenu -------------- next part -------------- x.1 is a matrix with 93 columns class(x.1) [1] "matrix" ################################################################################ x.1 41 42 43 44 45 EU0006MIndex 0.005000000 -0.033370000 1.431e-02 0.013870000 -0.05793000 DMSW1Curncy 0.064200000 -0.057800000 5.610e-02 -0.000600000 -0.15170000 DMSW2Curncy 0.096000000 -0.064500000 1.053e-01 -0.027300000 -0.23350000 DMSW3Curncy 0.058500000 -0.075500000 1.398e-01 -0.054700000 -0.24660000 DMSW4Curncy 0.026500000 -0.086500000 1.710e-01 -0.085000000 -0.23650000 DMSW5Curncy -0.011000000 -0.094000000 1.815e-01 -0.098300000 -0.22520000 DMSW6Curncy -0.036500000 -0.101000000 1.795e-01 -0.098400000 -0.21810000 DMSW7Curncy -0.056500000 -0.117500000 1.864e-01 -0.095900000 -0.21000000 DMSW8Curncy -0.073000000 -0.122500000 1.872e-01 -0.099200000 -0.20150000 DMSW9Curncy -0.086500000 -0.126500000 1.876e-01 -0.098600000 -0.19150000 DMSW10Curncy -0.107500000 -0.135500000 1.872e-01 -0.092700000 -0.18500000 DMSW12Curncy -0.119500000 -0.146500000 1.900e-01 -0.093000000 -0.17350000 DMSW15Curncy -0.132000000 -0.166000000 1.790e-01 -0.079000000 -0.15800000 DMSW20Curncy -0.130500000 -0.191000000 1.560e-01 -0.074500000 -0.13950000 DMSW30Curncy -0.131500000 -0.228000000 1.600e-01 -0.069000000 -0.12300000 EUSA40Curncy -0.133500000 -0.232200000 1.552e-01 -0.079500000 -0.10150000 EUSA50Curncy -0.132500000 -0.229700000 1.637e-01 -0.089500000 -0.10050000 Libor_OAS 0.001208618 -0.005033614 4.506e-05 -0.004526479 -0.01386261 46 47 48 49 50 EU0006MIndex -0.009380000 -0.040000000 0.048880000 0.006870000 0.052250000 DMSW1Curncy -0.060200000 -0.074300000 0.158500000 -0.020800000 0.127400000 DMSW2Curncy -0.102000000 -0.133000000 0.242600000 -0.062700000 0.183100000 DMSW3Curncy -0.129000000 -0.139900000 0.235900000 -0.085000000 0.179000000 DMSW4Curncy -0.166000000 -0.139900000 0.216400000 -0.098000000 0.166700000 DMSW5Curncy -0.147000000 -0.149900000 0.182400000 -0.114000000 0.147000000 DMSW6Curncy -0.134000000 -0.156500000 0.155000000 -0.127000000 0.125000000 DMSW7Curncy -0.181000000 -0.140000000 0.167500000 -0.133000000 0.104000000 DMSW8Curncy -0.173000000 -0.126500000 0.134000000 -0.140000000 0.088000000 DMSW9Curncy -0.162000000 -0.149900000 0.136400000 -0.145000000 0.075500000 DMSW10Curncy -0.146500000 -0.161500000 0.126500000 -0.148000000 0.066500000 DMSW12Curncy -0.141000000 -0.160000000 0.117500000 -0.153000000 0.054500000 DMSW15Curncy -0.131000000 -0.167000000 0.103000000 -0.155000000 0.044000000 DMSW20Curncy -0.113000000 -0.170000000 0.084000000 -0.161500000 0.034500000 DMSW30Curncy -0.109000000 -0.179900000 0.074900000 -0.168000000 0.022000000 EUSA40Curncy -0.110000000 -0.185000000 0.075000000 -0.174000000 0.032500000 EUSA50Curncy -0.112000000 -0.185000000 0.078000000 -0.177000000 0.031500000 Libor_OAS -0.002243875 0.006692975 -0.002139178 0.006372163 -0.000319492 51 52 53 54 90 EU0006MIndex 0.172000000 0.22000000 0.03963000 0.05950000 -0.7918700 DMSW1Curncy 0.245000000 0.21430000 0.06620000 0.06400000 -0.4600000 DMSW2Curncy 0.272300000 0.15520000 0.07500000 0.11700000 -0.4220000 DMSW3Curncy 0.273000000 0.12030000 0.07420000 0.14200000 -0.3860000 DMSW4Curncy 0.287300000 0.10200000 0.03350000 0.16210000 -0.3110000 DMSW5Curncy 0.286500000 0.09170000 -0.00370000 0.17860000 -0.2255000 DMSW6Curncy 0.283500000 0.07870000 -0.02970000 0.18490000 -0.1640000 DMSW7Curncy 0.270500000 0.07110000 -0.05910000 0.19570000 -0.1090000 DMSW8Curncy 0.260500000 0.06110000 -0.07410000 0.19390000 -0.0500000 DMSW9Curncy 0.253000000 0.05220000 -0.09420000 0.19720000 -0.0410000 DMSW10Curncy 0.245000000 0.04630000 -0.10830000 0.19750000 -0.0175000 DMSW12Curncy 0.230000000 0.04000000 -0.12700000 0.19260000 0.0255000 DMSW15Curncy 0.211000000 0.03880000 -0.14180000 0.18110000 0.0885000 DMSW20Curncy 0.190000000 0.03250000 -0.15450000 0.18250000 0.1165000 DMSW30Curncy 0.191000000 0.02150000 -0.17650000 0.18500000 0.1295000 EUSA40Curncy 0.174500000 0.00850000 -0.18350000 0.18000000 0.1145000 EUSA50Curncy 0.172500000 0.00450000 -0.18950000 0.16800000 0.0805000 Libor_OAS -0.006313754 -0.01380074 -0.01809107 -0.01037939 0.2329775 91 92 93 94 20 EU0006MIndex -0.24688 -0.26125000 -0.11000000 -0.09062000 -0.020060000 DMSW1Curncy -0.19750 -0.27850000 -0.03600000 -0.13800000 0.030500000 DMSW2Curncy -0.17800 -0.26900000 -0.01800000 -0.07900000 0.112000000 DMSW3Curncy -0.18000 -0.24900000 0.00900000 -0.00300000 0.178700000 DMSW4Curncy -0.20600 -0.18100000 0.02500000 0.08200000 0.191300000 DMSW5Curncy -0.22050 -0.14600000 0.03800000 0.13600000 0.197000000 DMSW6Curncy -0.23900 -0.11800000 0.05200000 0.18200000 0.180500000 DMSW7Curncy -0.25200 -0.10100000 0.05800000 0.20500000 0.162300000 DMSW8Curncy -0.26600 -0.09100000 0.06050000 0.23750000 0.144700000 DMSW9Curncy -0.27100 -0.09000000 0.06350000 0.24350000 0.135000000 DMSW10Curncy -0.27200 -0.07700000 0.06000000 0.26500000 0.126000000 DMSW12Curncy -0.26000 -0.06950000 0.04000000 0.26600000 0.119000000 DMSW15Curncy -0.21350 -0.03200000 0.02600000 0.25400000 0.117000000 DMSW20Curncy -0.14900 0.00850000 0.03400000 0.24400000 0.132700000 DMSW30Curncy -0.20800 0.16150000 0.10400000 0.22800000 0.140200000 EUSA40Curncy -0.25600 0.28150000 0.09200000 0.21600000 0.145100000 EUSA50Curncy -0.27650 0.36500000 0.06800000 0.20100000 0.137800000 Libor_OAS -0.05197 0.08488708 0.08660846 0.09570806 0.002690001 23 24 33 63 64 EU0006MIndex -0.11113000 0.013000000 0.16200000 0.13744000 0.035690000 DMSW1Curncy -0.09750000 0.180000000 0.25750000 0.10800000 0.007000000 DMSW2Curncy 0.00250000 0.396500000 0.33950000 0.08450000 -0.020000000 DMSW3Curncy 0.04800000 0.499000000 0.35250000 0.06770000 -0.024400000 DMSW4Curncy 0.05350000 0.504000000 0.32250000 0.05400000 -0.026400000 DMSW5Curncy 0.06170000 0.492300000 0.32650000 0.04120000 -0.030600000 DMSW6Curncy 0.07500000 0.471500000 0.30250000 0.03050000 -0.033000000 DMSW7Curncy 0.08250000 0.435000000 0.25750000 0.02380000 -0.037200000 DMSW8Curncy 0.07700000 0.422500000 0.25250000 0.01680000 -0.041500000 DMSW9Curncy 0.07450000 0.411500000 0.23750000 0.00890000 -0.043900000 DMSW10Curncy 0.07200000 0.391500000 0.22600000 0.00240000 -0.044900000 DMSW12Curncy 0.07670000 0.375700000 0.22350000 -0.01160000 -0.043900000 DMSW15Curncy 0.09100000 0.334500000 0.19550000 -0.03260000 -0.035900000 DMSW20Curncy 0.11100000 0.308500000 0.16750000 -0.05460000 -0.024900000 DMSW30Curncy 0.12950000 0.296000000 0.15050000 -0.07310000 -0.025900000 EUSA40Curncy 0.13750000 0.284900000 0.14350000 -0.08700000 -0.024500000 EUSA50Curncy 0.14500000 0.284900000 0.14450000 -0.10000000 -0.022500000 Libor_OAS 0.01765164 -0.008542735 0.00763029 0.01485481 -0.008369592 65 66 67 68 69 EU0006MIndex 0.11262000 0.067380000 0.027500000 0.09637000 0.093380000 DMSW1Curncy 0.18500000 0.075000000 -0.034500000 0.13250000 0.096000000 DMSW2Curncy 0.25700000 0.078500000 -0.085000000 0.12750000 0.100000000 DMSW3Curncy 0.28170000 0.093500000 -0.125000000 0.13010000 0.106900000 DMSW4Curncy 0.28940000 0.091000000 -0.120000000 0.13510000 0.085900000 DMSW5Curncy 0.28640000 0.105000000 -0.120000000 0.12510000 0.088900000 DMSW6Curncy 0.28650000 0.108500000 -0.123500000 0.12670000 0.086800000 DMSW7Curncy 0.28700000 0.114900000 -0.135000000 0.14010000 0.076900000 DMSW8Curncy 0.28720000 0.119500000 -0.128500000 0.12390000 0.081600000 DMSW9Curncy 0.28810000 0.125400000 -0.135000000 0.13510000 0.072400000 DMSW10Curncy 0.28710000 0.131400000 -0.140000000 0.13510000 0.074400000 DMSW12Curncy 0.28210000 0.137400000 -0.135000000 0.14010000 0.065400000 DMSW15Curncy 0.27410000 0.154200000 -0.150700000 0.15340000 0.059000000 DMSW20Curncy 0.26510000 0.145400000 -0.125000000 0.15010000 0.050400000 DMSW30Curncy 0.25310000 0.152400000 -0.120000000 0.15130000 0.048200000 EUSA40Curncy 0.24360000 0.155400000 -0.115000000 0.15510000 0.045400000 EUSA50Curncy 0.23660000 0.157400000 -0.110000000 0.15510000 0.047400000 Libor_OAS 0.00186817 -0.002365185 0.005187709 -0.01461509 0.002439231 70 81 89 4 5 EU0006MIndex 0.115000000 0.156880000 -0.92375000 -0.108000000 0.01413000 DMSW1Curncy 0.194000000 0.251500000 -0.75000000 0.038500000 0.15450000 DMSW2Curncy 0.285500000 0.272500000 -0.46800000 0.275000000 0.27530000 DMSW3Curncy 0.301500000 0.248500000 -0.27850000 0.322800000 0.30880000 DMSW4Curncy 0.309000000 0.232000000 -0.24500000 0.292500000 0.33400000 DMSW5Curncy 0.306500000 0.211000000 -0.22200000 0.261500000 0.36000000 DMSW6Curncy 0.300000000 0.200000000 -0.20400000 0.247000000 0.36600000 DMSW7Curncy 0.294000000 0.188500000 -0.20500000 0.233800000 0.36570000 DMSW8Curncy 0.287500000 0.178500000 -0.20760000 0.225000000 0.37000000 DMSW9Curncy 0.282500000 0.171000000 -0.19700000 0.207600000 0.37020000 DMSW10Curncy 0.276000000 0.166500000 -0.19920000 0.177300000 0.36320000 DMSW12Curncy 0.269500000 0.166500000 -0.20270000 0.178800000 0.34250000 DMSW15Curncy 0.260000000 0.150000000 -0.21600000 0.152500000 0.30630000 DMSW20Curncy 0.247000000 0.150500000 -0.15170000 0.132500000 0.25380000 DMSW30Curncy 0.234000000 0.134000000 -0.06070000 0.093800000 0.22250000 EUSA40Curncy 0.226000000 0.133000000 -0.04900000 0.081200000 0.21500000 EUSA50Curncy 0.219000000 0.135000000 -0.02100000 0.078800000 0.20500000 Libor_OAS -0.005149682 0.003585315 0.01041321 0.008700073 0.03094386 14 15 16 17 19 EU0006MIndex -0.16125000 -0.02569000 -0.18143000 -0.18925000 -0.260570000 DMSW1Curncy -0.36320000 0.02420000 -0.08000000 -0.28230000 -0.279000000 DMSW2Curncy -0.39950000 0.03350000 0.00780000 -0.38780000 -0.298000000 DMSW3Curncy -0.29830000 0.06450000 0.00850000 -0.39950000 -0.309700000 DMSW4Curncy -0.38120000 0.09370000 0.00880000 -0.39150000 -0.292300000 DMSW5Curncy -0.36870000 0.12820000 -0.00150000 -0.36470000 -0.295000000 DMSW6Curncy -0.34400000 0.14470000 -0.01340000 -0.34680000 -0.271500000 DMSW7Curncy -0.32500000 0.15500000 -0.02550000 -0.33750000 -0.246300000 DMSW8Curncy -0.30380000 0.15900000 -0.03270000 -0.30830000 -0.218700000 DMSW9Curncy -0.28380000 0.16350000 -0.03330000 -0.31220000 -0.196000000 DMSW10Curncy -0.26630000 0.16550000 -0.03020000 -0.27780000 -0.171000000 DMSW12Curncy -0.23250000 0.15750000 -0.01530000 -0.28070000 -0.137700000 DMSW15Curncy -0.19130000 0.16500000 -0.02700000 -0.26550000 -0.089000000 DMSW20Curncy -0.16630000 0.17250000 -0.03370000 -0.22130000 -0.047000000 DMSW30Curncy -0.13130000 0.17000000 -0.02570000 -0.21430000 -0.009200000 EUSA40Curncy -0.13010000 0.17500000 -0.02490000 -0.21380000 0.015000000 EUSA50Curncy -0.13010000 0.17010000 -0.02250000 -0.21380000 0.017500000 Libor_OAS -0.01490770 0.01352547 0.04839254 -0.01363033 -0.001718632 55 56 57 58 59 EU0006MIndex 0.083120000 0.20563000 0.048000000 0.06162000 0.150630000 DMSW1Curncy 0.087300000 0.27440000 0.024600000 0.06870000 0.159000000 DMSW2Curncy 0.074800000 0.30620000 0.067700000 0.02570000 0.164300000 DMSW3Curncy 0.057100000 0.32190000 0.096900000 0.00670000 0.159000000 DMSW4Curncy 0.055400000 0.32790000 0.117700000 -0.00090000 0.149200000 DMSW5Curncy 0.047800000 0.32920000 0.133800000 -0.00020000 0.140800000 DMSW6Curncy 0.042400000 0.32860000 0.148600000 0.00220000 0.130300000 DMSW7Curncy 0.035000000 0.32860000 0.159600000 0.00760000 0.120300000 DMSW8Curncy 0.030000000 0.32770000 0.168800000 0.01000000 0.111000000 DMSW9Curncy 0.022800000 0.32860000 0.173600000 0.01730000 0.101100000 DMSW10Curncy 0.018800000 0.32510000 0.177800000 0.02360000 0.094100000 DMSW12Curncy 0.011700000 0.32370000 0.178500000 0.04100000 0.077100000 DMSW15Curncy 0.006600000 0.31730000 0.182400000 0.05460000 0.065800000 DMSW20Curncy -0.003500000 0.30400000 0.184000000 0.08150000 0.045000000 DMSW30Curncy -0.008000000 0.29800000 0.182500000 0.09600000 0.030000000 EUSA40Curncy -0.007000000 0.29400000 0.182500000 0.10500000 0.024000000 EUSA50Curncy -0.009000000 0.29100000 0.185500000 0.11800000 0.020000000 Libor_OAS -0.004074941 -0.01879896 0.004026018 -0.01844149 -0.001023114 60 61 62 79 80 EU0006MIndex 0.08537000 0.11275000 0.121500000 0.02500000 0.338120000 DMSW1Curncy 0.02380000 0.09510000 0.104000000 -0.05350000 0.413000000 DMSW2Curncy -0.05820000 0.00700000 0.068500000 -0.15150000 0.441000000 DMSW3Curncy -0.09290000 -0.06320000 0.056500000 -0.16600000 0.382500000 DMSW4Curncy -0.10970000 -0.09930000 0.041600000 -0.15450000 0.308000000 DMSW5Curncy -0.11980000 -0.12330000 0.026100000 -0.14150000 0.249000000 DMSW6Curncy -0.12230000 -0.13720000 0.007500000 -0.12300000 0.197500000 DMSW7Curncy -0.12330000 -0.14920000 -0.008800000 -0.10550000 0.161500000 DMSW8Curncy -0.12290000 -0.15590000 -0.022100000 -0.08650000 0.133500000 DMSW9Curncy -0.12310000 -0.16000000 -0.034000000 -0.07500000 0.117000000 DMSW10Curncy -0.12290000 -0.16250000 -0.045500000 -0.06650000 0.108000000 DMSW12Curncy -0.11960000 -0.16950000 -0.061500000 -0.05450000 0.101000000 DMSW15Curncy -0.11580000 -0.17650000 -0.080500000 -0.05850000 0.103000000 DMSW20Curncy -0.11150000 -0.18650000 -0.101500000 -0.04650000 0.075000000 DMSW30Curncy -0.10750000 -0.19050000 -0.127000000 -0.05700000 0.048000000 EUSA40Curncy -0.11050000 -0.19550000 -0.133000000 -0.06700000 0.041000000 EUSA50Curncy -0.10950000 -0.19750000 -0.143000000 -0.07400000 0.044000000 Libor_OAS -0.01044126 -0.00066107 -0.003654222 -0.05272334 -0.000459561 88 18 21 22 25 EU0006MIndex -0.905000000 -0.08675000 0.02025000 -0.25212000 0.087500000 DMSW1Curncy -0.706000000 -0.07970000 -0.01400000 -0.23750000 0.120000000 DMSW2Curncy -0.522500000 -0.10700000 -0.02600000 -0.30850000 -0.016500000 DMSW3Curncy -0.567500000 -0.12550000 -0.02400000 -0.37150000 -0.006500000 DMSW4Curncy -0.552000000 -0.14250000 0.00400000 -0.40750000 0.084000000 DMSW5Curncy -0.546000000 -0.14400000 0.00100000 -0.39500000 0.058000000 DMSW6Curncy -0.547000000 -0.14300000 0.00400000 -0.40050000 0.041000000 DMSW7Curncy -0.545000000 -0.12750000 0.00730000 -0.39580000 0.030000000 DMSW8Curncy -0.552400000 -0.13450000 0.00830000 -0.38480000 0.009200000 DMSW9Curncy -0.537000000 -0.11450000 0.00850000 -0.37800000 -0.012200000 DMSW10Curncy -0.544800000 -0.14000000 0.00720000 -0.37120000 -0.018500000 DMSW12Curncy -0.520800000 -0.12130000 0.00700000 -0.35970000 -0.053700000 DMSW15Curncy -0.497500000 -0.11950000 0.00800000 -0.34350000 -0.063500000 DMSW20Curncy -0.518800000 -0.15270000 0.01170000 -0.31720000 -0.096000000 DMSW30Curncy -0.659300000 -0.14550000 0.02850000 -0.27750000 -0.120500000 EUSA40Curncy -0.754000000 -0.14630000 0.04000000 -0.22750000 -0.130000000 EUSA50Curncy -0.815000000 -0.14630000 0.04230000 -0.18750000 -0.129900000 Libor_OAS 0.003002001 0.02014416 0.01459044 0.01335764 -0.008345219 26 27 28 29 30 EU0006MIndex -0.082310000 0.101440000 0.026370000 -0.07325000 -0.02950000 DMSW1Curncy -0.218500000 0.286500000 0.107500000 -0.18750000 -0.03700000 DMSW2Curncy -0.201500000 0.413700000 0.165300000 -0.26250000 -0.02700000 DMSW3Curncy -0.251000000 0.428700000 0.172800000 -0.25750000 -0.06750000 DMSW4Curncy -0.319000000 0.418700000 0.170800000 -0.24150000 -0.07100000 DMSW5Curncy -0.291000000 0.404300000 0.168200000 -0.22750000 -0.06670000 DMSW6Curncy -0.261000000 0.381000000 0.160500000 -0.20850000 -0.05900000 DMSW7Curncy -0.224500000 0.350200000 0.147300000 -0.18700000 -0.04850000 DMSW8Curncy -0.198700000 0.324500000 0.142500000 -0.17350000 -0.04300000 DMSW9Curncy -0.179300000 0.304300000 0.137200000 -0.16450000 -0.03250000 DMSW10Curncy -0.161000000 0.280800000 0.135700000 -0.15350000 -0.02700000 DMSW12Curncy -0.131200000 0.253200000 0.126500000 -0.14450000 -0.01400000 DMSW15Curncy -0.093500000 0.203500000 0.116000000 -0.13050000 0.00970000 DMSW20Curncy -0.062000000 0.178500000 0.090000000 -0.11950000 0.02150000 DMSW30Curncy -0.033000000 0.132800000 0.089700000 -0.10950000 0.01350000 EUSA40Curncy -0.024900000 0.122500000 0.089900000 -0.10720000 0.00600000 EUSA50Curncy -0.022500000 0.120000000 0.090000000 -0.10480000 0.00350000 Libor_OAS -0.004291824 0.002813593 -0.001309296 -0.00870135 -0.02041407 31 32 34 35 36 EU0006MIndex -0.090370000 -0.103630000 0.042630000 0.048500000 0.00562000 DMSW1Curncy -0.201000000 -0.108500000 0.136500000 0.041500000 -0.03000000 DMSW2Curncy -0.318000000 -0.120000000 0.194500000 0.042000000 -0.06650000 DMSW3Curncy -0.307000000 -0.128500000 0.208000000 0.027500000 -0.08150000 DMSW4Curncy -0.291500000 -0.134500000 0.237500000 0.004000000 -0.09350000 DMSW5Curncy -0.273300000 -0.141000000 0.223500000 -0.018000000 -0.09550000 DMSW6Curncy -0.256500000 -0.125500000 0.207500000 -0.027000000 -0.10200000 DMSW7Curncy -0.239000000 -0.110500000 0.212500000 -0.033000000 -0.06950000 DMSW8Curncy -0.221000000 -0.105000000 0.191000000 -0.043500000 -0.10050000 DMSW9Curncy -0.207500000 -0.097000000 0.183500000 -0.055000000 -0.09850000 DMSW10Curncy -0.195000000 -0.096000000 0.179500000 -0.062500000 -0.09750000 DMSW12Curncy -0.177500000 -0.098500000 0.158500000 -0.070000000 -0.09550000 DMSW15Curncy -0.170200000 -0.090500000 0.150500000 -0.089000000 -0.09550000 DMSW20Curncy -0.144000000 -0.080500000 0.143000000 -0.110500000 -0.09750000 DMSW30Curncy -0.114500000 -0.081000000 0.134500000 -0.126000000 -0.09350000 EUSA40Curncy -0.102500000 -0.078500000 0.127500000 -0.122000000 -0.09400000 EUSA50Curncy -0.100000000 -0.079500000 0.122500000 -0.120000000 -0.09400000 Libor_OAS 0.009403827 0.001808508 -0.001577021 0.003952737 -0.01201065 37 38 39 40 71 EU0006MIndex -0.033000000 0.043000000 -0.014250000 0.013000000 0.06375000 DMSW1Curncy -0.101000000 0.102000000 -0.064000000 -0.020200000 0.06300000 DMSW2Curncy -0.180500000 0.083500000 -0.131000000 -0.055500000 0.07100000 DMSW3Curncy -0.206500000 0.050000000 -0.151000000 -0.066500000 0.10300000 DMSW4Curncy -0.220500000 0.024500000 -0.143200000 -0.099800000 0.12050000 DMSW5Curncy -0.227500000 0.013000000 -0.140500000 -0.113500000 0.13700000 DMSW6Curncy -0.211000000 -0.007000000 -0.135700000 -0.123800000 0.15100000 DMSW7Curncy -0.237500000 -0.020300000 -0.133200000 -0.127000000 0.16000000 DMSW8Curncy -0.196500000 -0.025500000 -0.128500000 -0.132000000 0.16950000 DMSW9Curncy -0.191500000 -0.030500000 -0.122000000 -0.136000000 0.17250000 DMSW10Curncy -0.183500000 -0.036000000 -0.122000000 -0.122500000 0.17450000 DMSW12Curncy -0.179500000 -0.035500000 -0.117500000 -0.129500000 0.17900000 DMSW15Curncy -0.162500000 -0.050500000 -0.098000000 -0.135500000 0.18500000 DMSW20Curncy -0.149500000 -0.044500000 -0.092500000 -0.143500000 0.18950000 DMSW30Curncy -0.138500000 -0.036500000 -0.084700000 -0.147300000 0.19550000 EUSA40Curncy -0.135000000 -0.030000000 -0.080500000 -0.147000000 0.19650000 EUSA50Curncy -0.135000000 -0.032500000 -0.071000000 -0.152000000 0.19650000 Libor_OAS 0.005478926 0.008198818 -0.001437366 0.005393445 -0.02445343 72 73 74 75 76 EU0006MIndex 0.06837000 0.37600000 -0.00375000 -0.14312000 0.14000000 DMSW1Curncy -0.00100000 0.09900000 -0.00600000 -0.03550000 -0.00800000 DMSW2Curncy -0.08950000 -0.04600000 -0.01950000 0.02400000 -0.12700000 DMSW3Curncy -0.11350000 -0.08000000 -0.01750000 0.01300000 -0.12600000 DMSW4Curncy -0.12900000 -0.08350000 -0.00800000 0.03000000 -0.16000000 DMSW5Curncy -0.13700000 -0.08750000 0.00300000 0.01900000 -0.14100000 DMSW6Curncy -0.14400000 -0.08550000 0.01850000 0.00350000 -0.12200000 DMSW7Curncy -0.14300000 -0.08400000 0.03350000 -0.01100000 -0.10200000 DMSW8Curncy -0.14650000 -0.07800000 0.04450000 -0.02100000 -0.08600000 DMSW9Curncy -0.14750000 -0.07100000 0.05450000 -0.02800000 -0.07100000 DMSW10Curncy -0.14750000 -0.06250000 0.06300000 -0.03750000 -0.05500000 DMSW12Curncy -0.15050000 -0.04350000 0.06800000 -0.04250000 -0.03400000 DMSW15Curncy -0.16000000 -0.00950000 0.07050000 -0.05500000 -0.02200000 DMSW20Curncy -0.15850000 -0.00050000 0.07300000 -0.05250000 0.02300000 DMSW30Curncy -0.16400000 0.01300000 0.07300000 -0.06000000 0.04750000 EUSA40Curncy -0.16900000 0.01600000 0.07900000 -0.06700000 0.05450000 EUSA50Curncy -0.17400000 0.02000000 0.08200000 -0.07200000 0.06050000 Libor_OAS -0.07796062 -0.05807047 0.02342743 0.01514968 -0.09638523 77 78 82 83 84 EU0006MIndex -0.04813000 -0.34187000 0.04250000 0.20250000 0.01937000 DMSW1Curncy 0.04550000 -0.50350000 0.31500000 0.25650000 -0.29550000 DMSW2Curncy 0.09150000 -0.57450000 0.47450000 0.36500000 -0.38370000 DMSW3Curncy 0.08950000 -0.54550000 0.45900000 0.41150000 -0.37490000 DMSW4Curncy 0.14400000 -0.54200000 0.40800000 0.41900000 -0.33250000 DMSW5Curncy 0.13100000 -0.49600000 0.36900000 0.39600000 -0.29150000 DMSW6Curncy 0.13100000 -0.46300000 0.33500000 0.36500000 -0.26450000 DMSW7Curncy 0.12150000 -0.42550000 0.30950000 0.32650000 -0.24600000 DMSW8Curncy 0.11850000 -0.39650000 0.29050000 0.28950000 -0.23200000 DMSW9Curncy 0.11350000 -0.37050000 0.27350000 0.25600000 -0.22300000 DMSW10Curncy 0.11050000 -0.35200000 0.25800000 0.22700000 -0.21300000 DMSW12Curncy 0.09650000 -0.31600000 0.23450000 0.17350000 -0.20100000 DMSW15Curncy 0.10050000 -0.27850000 0.19500000 0.16500000 -0.21000000 DMSW20Curncy 0.05650000 -0.24000000 0.18950000 0.05750000 -0.17600000 DMSW30Curncy 0.02900000 -0.20350000 0.18450000 -0.01750000 -0.16500000 EUSA40Curncy 0.01050000 -0.19100000 0.18750000 -0.05250000 -0.17000000 EUSA50Curncy -0.00300000 -0.18150000 0.18950000 -0.07950000 -0.18000000 Libor_OAS 0.05813796 -0.02651261 0.02975544 -0.03108934 -0.02503904 85 86 87 2 6 EU0006MIndex 0.01125000 0.2100000 -0.56375000 -0.579000000 0.154500000 DMSW1Curncy 0.04350000 -0.0830000 -1.03000000 -0.491000000 0.246000000 DMSW2Curncy -0.11530000 -0.1790000 -1.01450000 -0.353500000 0.220200000 DMSW3Curncy -0.15360000 -0.0875000 -0.87500000 -0.259500000 0.170200000 DMSW4Curncy -0.15950000 -0.0465000 -0.75700000 -0.185000000 0.120500000 DMSW5Curncy -0.15850000 -0.0030000 -0.67150000 -0.124000000 0.066300000 DMSW6Curncy -0.16000000 0.0275000 -0.57450000 -0.085500000 0.013000000 DMSW7Curncy -0.16750000 0.0405000 -0.46400000 -0.071500000 -0.020000000 DMSW8Curncy -0.17300000 0.0440000 -0.37200000 -0.053300000 -0.049500000 DMSW9Curncy -0.16550000 0.0320000 -0.29250000 -0.031000000 -0.075500000 DMSW10Curncy -0.16750000 0.0285000 -0.22650000 -0.014000000 -0.094500000 DMSW12Curncy -0.16200000 0.0145000 -0.15400000 0.010000000 -0.126200000 DMSW15Curncy -0.16650000 -0.0100000 -0.11200000 0.044500000 -0.141300000 DMSW20Curncy -0.15750000 -0.0470000 -0.16000000 0.067500000 -0.156200000 DMSW30Curncy -0.13950000 -0.1030000 -0.28050000 0.086500000 -0.173800000 EUSA40Curncy -0.12050000 -0.1140000 -0.32250000 0.082400000 -0.178700000 EUSA50Curncy -0.10950000 -0.1270000 -0.29550000 0.082500000 -0.176300000 Libor_OAS -0.02937073 -0.1661179 0.09827107 0.006805675 0.007755395 7 8 9 10 11 EU0006MIndex 0.002620000 0.18150000 -0.103000000 0.144630000 -0.0958800 DMSW1Curncy -0.000500000 0.36600000 -0.194000000 0.208500000 -0.2480000 DMSW2Curncy -0.035500000 0.42250000 -0.226500000 0.158500000 -0.3050000 DMSW3Curncy -0.069300000 0.44680000 -0.218000000 0.114500000 -0.2912000 DMSW4Curncy -0.013000000 0.39100000 -0.195700000 0.098200000 -0.2763000 DMSW5Curncy -0.005100000 0.36630000 -0.172200000 0.081900000 -0.2737000 DMSW6Curncy 0.013500000 0.32650000 -0.142300000 0.062300000 -0.2575000 DMSW7Curncy 0.019000000 0.31300000 -0.136500000 0.052500000 -0.2400000 DMSW8Curncy 0.021500000 0.29150000 -0.122700000 0.048700000 -0.2250000 DMSW9Curncy 0.027800000 0.28770000 -0.115500000 0.041500000 -0.2125000 DMSW10Curncy 0.041000000 0.28300000 -0.120500000 0.041500000 -0.2050000 DMSW12Curncy 0.047500000 0.29120000 -0.122800000 0.030300000 -0.2000000 DMSW15Curncy 0.062500000 0.26880000 -0.100000000 0.020000000 -0.2075000 DMSW20Curncy 0.099900000 0.24380000 -0.092500000 0.022500000 -0.2375000 DMSW30Curncy 0.115100000 0.24370000 -0.090500000 0.023000000 -0.2725000 EUSA40Curncy 0.119900000 0.23510000 -0.086300000 0.021300000 -0.2801000 EUSA50Curncy 0.117600000 0.23740000 -0.096200000 0.021300000 -0.2851000 Libor_OAS -0.007835379 0.01409837 0.000725314 0.003672631 -0.2692682 12 13 3 EU0006MIndex -0.1150000 -0.065000000 -0.195630000 DMSW1Curncy -0.2665000 -0.101500000 -0.310000000 DMSW2Curncy -0.3230000 -0.171000000 -0.383500000 DMSW3Curncy -0.3408000 -0.264200000 -0.389800000 DMSW4Curncy -0.2687000 -0.231300000 -0.403500000 DMSW5Curncy -0.2395000 -0.236800000 -0.404000000 DMSW6Curncy -0.2187000 -0.232300000 -0.415500000 DMSW7Curncy -0.2075000 -0.217500000 -0.419500000 DMSW8Curncy -0.2025000 -0.206200000 -0.444500000 DMSW9Curncy -0.1975000 -0.198700000 -0.464800000 DMSW10Curncy -0.1925000 -0.193700000 -0.456000000 DMSW12Curncy -0.1800000 -0.190000000 -0.495300000 DMSW15Curncy -0.1625000 -0.186200000 -0.525300000 DMSW20Curncy -0.1375000 -0.166200000 -0.546500000 DMSW30Curncy -0.1325000 -0.151200000 -0.555800000 EUSA40Curncy -0.1312000 -0.151200000 -0.559900000 EUSA50Curncy -0.1262000 -0.151200000 -0.575100000 Libor_OAS 0.2337522 0.002620822 0.007712663 ######################################################################################## pbVector is a matrix with 92 probabilities class(pbVector) [1] "matrix" pbVector [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.02005013 0.02005013 0.01619433 0.02005013 0.005444646 0.02005013 [,7] [,8] [,9] [,10] [,11] [,12] [1,] 0.02005013 0.007017544 0.02005013 0.007017544 0.007017544 0.007017544 [,13] [,14] [,15] [,16] [,17] [,18] [1,] 0.02005013 0.01619433 0.005444646 0.02005013 0.005444646 0.01619433 [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] [,27] [,28] [,29] [1,] 0.01619433 0 0 0 0 0 0 0 0 0 0 [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38] [,39] [,40] [,41] [1,] 0 0 0 0 0 0 0 0 0 0 0 0 [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50] [,51] [,52] [,53] [1,] 0 0 0 0 0 0 0 0 0 0 0 0 [,54] [,55] [,56] [,57] [,58] [,59] [,60] [,61] [,62] [,63] [,64] [,65] [1,] 0 0 0 0 0 0 0 0 0 0 0 0 [,66] [,67] [,68] [,69] [,70] [,71] [,72] [,73] [,74] [,75] [,76] [,77] [1,] 0 0 0 0 0 0 0 0 0 0 0 0 [,78] [,79] [,80] [,81] [,82] [,83] [,84] [,85] [,86] [,87] [,88] [,89] [1,] 0 0 0 0 0 0 0 0 0 0 0 0 [,90] [,91] [,92] [,93] [1,] 0 0 0 0 ######################################################################################### y<-sample(x.1[,1:93],1,replace=T,prob=pbVector) Error in sample(x.1[, 1:93], 1, replace = T, prob = pbVector) : incorrect number of probabilities ##Question 1 : why do I get the above error message? If I convert x.1 into a dataframe then it works. x.1<-data.frame(x.1) y<-sample(x.1[,1:93],1,replace=T,prob=pbVector) y X47 EU0006MIndex -0.040000000 DMSW1Curncy -0.074300000 DMSW2Curncy -0.133000000 DMSW3Curncy -0.139900000 DMSW4Curncy -0.139900000 DMSW5Curncy -0.149900000 DMSW6Curncy -0.156500000 DMSW7Curncy -0.140000000 DMSW8Curncy -0.126500000 DMSW9Curncy -0.149900000 DMSW10Curncy -0.161500000 DMSW12Curncy -0.160000000 DMSW15Curncy -0.167000000 DMSW20Curncy -0.170000000 DMSW30Curncy -0.179900000 EUSA40Curncy -0.185000000 EUSA50Curncy -0.185000000 Libor_OAS 0.006692975 Question 2: Now y is a also a dataframe and therefore I cannot put it into an array in the right order. deltaY<-array(dim=c(18,36)) deltaY[,1]<-y Output of deltaY is deltaY [[1]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[2]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[3]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[4]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[5]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[6]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[7]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[8]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[9]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[10]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[11]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[12]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[13]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[14]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[15]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[16]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[17]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[18]] [1] -0.040000000 -0.074300000 -0.133000000 -0.139900000 -0.139900000 [6] -0.149900000 -0.156500000 -0.140000000 -0.126500000 -0.149900000 [11] -0.161500000 -0.160000000 -0.167000000 -0.170000000 -0.179900000 [16] -0.185000000 -0.185000000 0.006692975 [[19]] [1] NA [[20]] [1] NA [[21]] [1] NA - - - [[646]] [1] NA [[647]] [1] NA [[648]] [1] NA ##################################################################################### I want the target output of deltaY[,1] to be of the order. HOw can I do that? if I use x.1 not as a dataframe then I cannot use the function sample !!!! [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] -0.040000000 NA NA NA NA NA NA NA NA NA NA NA [2,] -0.074300000 NA NA NA NA NA NA NA NA NA NA NA [3,] -0.133000000 NA NA NA NA NA NA NA NA NA NA NA [4,] -0.139900000 NA NA NA NA NA NA NA NA NA NA NA [5,] -0.139900000 NA NA NA NA NA NA NA NA NA NA NA [6,] -0.149900000 NA NA NA NA NA NA NA NA NA NA NA [7,] -0.156500000 NA NA NA NA NA NA NA NA NA NA NA [8,] -0.140000000 NA NA NA NA NA NA NA NA NA NA NA [9,] -0.126500000 NA NA NA NA NA NA NA NA NA NA NA [10,] -0.149900000 NA NA NA NA NA NA NA NA NA NA NA [11,] -0.161500000 NA NA NA NA NA NA NA NA NA NA NA [12,] -0.160000000 NA NA NA NA NA NA NA NA NA NA NA [13,] -0.167000000 NA NA NA NA NA NA NA NA NA NA NA [14,] -0.170000000 NA NA NA NA NA NA NA NA NA NA NA [15,] -0.179900000 NA NA NA NA NA NA NA NA NA NA NA [16,] -0.185000000 NA NA NA NA NA NA NA NA NA NA NA [17,] -0.185000000 NA NA NA NA NA NA NA NA NA NA NA [18,] 0.006692975 NA NA NA NA NA NA NA NA NA NA NA [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [1,] NA NA NA NA NA NA NA NA NA NA NA NA [2,] NA NA NA NA NA NA NA NA NA NA NA NA [3,] NA NA NA NA NA NA NA NA NA NA NA NA [4,] NA NA NA NA NA NA NA NA NA NA NA NA [5,] NA NA NA NA NA NA NA NA NA NA NA NA [6,] NA NA NA NA NA NA NA NA NA NA NA NA [7,] NA NA NA NA NA NA NA NA NA NA NA NA [8,] NA NA NA NA NA NA NA NA NA NA NA NA [9,] NA NA NA NA NA NA NA NA NA NA NA NA [10,] NA NA NA NA NA NA NA NA NA NA NA NA [11,] NA NA NA NA NA NA NA NA NA NA NA NA [12,] NA NA NA NA NA NA NA NA NA NA NA NA [13,] NA NA NA NA NA NA NA NA NA NA NA NA [14,] NA NA NA NA NA NA NA NA NA NA NA NA [15,] NA NA NA NA NA NA NA NA NA NA NA NA [16,] NA NA NA NA NA NA NA NA NA NA NA NA [17,] NA NA NA NA NA NA NA NA NA NA NA NA [18,] NA NA NA NA NA NA NA NA NA NA NA NA [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [1,] NA NA NA NA NA NA NA NA NA NA NA NA [2,] NA NA NA NA NA NA NA NA NA NA NA NA [3,] NA NA NA NA NA NA NA NA NA NA NA NA [4,] NA NA NA NA NA NA NA NA NA NA NA NA [5,] NA NA NA NA NA NA NA NA NA NA NA NA [6,] NA NA NA NA NA NA NA NA NA NA NA NA [7,] NA NA NA NA NA NA NA NA NA NA NA NA [8,] NA NA NA NA NA NA NA NA NA NA NA NA [9,] NA NA NA NA NA NA NA NA NA NA NA NA [10,] NA NA NA NA NA NA NA NA NA NA NA NA [11,] NA NA NA NA NA NA NA NA NA NA NA NA [12,] NA NA NA NA NA NA NA NA NA NA NA NA [13,] NA NA NA NA NA NA NA NA NA NA NA NA [14,] NA NA NA NA NA NA NA NA NA NA NA NA [15,] NA NA NA NA NA NA NA NA NA NA NA NA [16,] NA NA NA NA NA NA NA NA NA NA NA NA [17,] NA NA NA NA NA NA NA NA NA NA NA NA [18,] NA NA NA NA NA NA NA NA NA NA NA NA