[R] extract the data that match
Peter Alspach
Peter.Alspach at plantandfood.co.nz
Wed Feb 17 03:55:21 CET 2010
Tena koe Roslina
It is not entirely clear to me what you want to do, but have you looked at match or %in%? Or do you simply want yourData[yourData[,2]==yourData[,3],]?
Also, you might need to bear in mind issues with floating point arithmetic which is a frequent question on this list.
HTH .....
Peter Alspach
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Roslina Zakaria
> Sent: Wednesday, 17 February 2010 3:39 p.m.
> To: r-help at r-project.org
> Subject: [R] extract the data that match
>
> Hi r-users,
>
> I would like to extract the data that match. Attached is my data:
> I'm interested in matchind the value in column 'intg' with
> value in column 'rand_no'
> > cbind(z=z,intg=dd,rand_no = rr)
> z intg rand_no
> [1,] 0.00 0.000 0.001
> [2,] 0.01 0.000 0.002
> [3,] 0.02 0.000 0.002
> [4,] 0.03 0.000 0.003
> [5,] 0.04 0.000 0.003
> [6,] 0.05 0.000 0.004
> [7,] 0.06 0.000 0.004
> [8,] 0.07 0.000 0.004
> [9,] 0.08 0.000 0.004
> [10,] 0.09 0.000 0.008
> [11,] 0.10 0.000 0.008
> [12,] 0.11 0.000 0.008
> [13,] 0.12 0.000 0.009
> [14,] 0.13 0.000 0.009
> [15,] 0.14 0.000 0.010
> [16,] 0.15 0.000 0.010
> [17,] 0.16 0.001 0.010
> [18,] 0.17 0.001 0.011
> [19,] 0.18 0.001 0.012
> [20,] 0.19 0.001 0.012
> [21,] 0.20 0.001 0.012
> [22,] 0.21 0.001 0.012
> [23,] 0.22 0.002 0.013
> [24,] 0.23 0.002 0.014
> [25,] 0.24 0.002 0.014
> [26,] 0.25 0.002 0.014
> [27,] 0.26 0.003 0.015
> [28,] 0.27 0.003 0.016
> [29,] 0.28 0.003 0.016
> [30,] 0.29 0.004 0.017
> [31,] 0.30 0.004 0.017
> [32,] 0.31 0.005 0.018
> [33,] 0.32 0.005 0.019
> [34,] 0.33 0.005 0.020
> [35,] 0.34 0.006 0.020
> [36,] 0.35 0.006 0.020
> [37,] 0.36 0.007 0.021
> [38,] 0.37 0.007 0.024
> [39,] 0.38 0.008 0.025
> [40,] 0.39 0.008 0.025
> [41,] 0.40 0.009 0.026
> [42,] 0.41 0.010 0.027
> [43,] 0.42 0.010 0.028
> [44,] 0.43 0.011 0.030
> [45,] 0.44 0.011 0.030
> [46,] 0.45 0.012 0.031
> [47,] 0.46 0.013 0.031
> [48,] 0.47 0.014 0.032
> [49,] 0.48 0.014 0.033
> [50,] 0.49 0.015 0.033
> [51,] 0.50 0.016 0.033
> [52,] 0.51 0.017 0.034
> [53,] 0.52 0.017 0.037
> [54,] 0.53 0.018 0.039
> [55,] 0.54 0.019 0.039
> [56,] 0.55 0.020 0.040
> [57,] 0.56 0.021 0.040
> [58,] 0.57 0.022 0.040
> [59,] 0.58 0.022 0.041
> [60,] 0.59 0.023 0.042
> [61,] 0.60 0.024 0.042
> [62,] 0.61 0.025 0.043
> [63,] 0.62 0.026 0.045
> [64,] 0.63 0.027 0.046
> [65,] 0.64 0.028 0.046
> [66,] 0.65 0.029 0.047
> [67,] 0.66 0.030 0.047
> [68,] 0.67 0.031 0.047
> [69,] 0.68 0.032 0.048
> [70,] 0.69 0.033 0.051
> [71,] 0.70 0.034 0.051
> [72,] 0.71 0.036 0.051
> [73,] 0.72 0.037 0.052
> [74,] 0.73 0.038 0.052
> [75,] 0.74 0.039 0.052
> [76,] 0.75 0.040 0.052
> [77,] 0.76 0.041 0.052
> [78,] 0.77 0.042 0.053
> [79,] 0.78 0.044 0.053
> [80,] 0.79 0.045 0.053
> [81,] 0.80 0.046 0.054
> [82,] 0.81 0.047 0.054
> [83,] 0.82 0.048 0.055
> [84,] 0.83 0.050 0.055
> [85,] 0.84 0.051 0.055
> [86,] 0.85 0.052 0.057
> [87,] 0.86 0.054 0.060
> [88,] 0.87 0.055 0.062
> [89,] 0.88 0.056 0.063
> [90,] 0.89 0.057 0.064
> [91,] 0.90 0.059 0.064
> [92,] 0.91 0.060 0.064
> [93,] 0.92 0.062 0.066
> [94,] 0.93 0.063 0.067
> [95,] 0.94 0.064 0.067
> [96,] 0.95 0.066 0.068
> [97,] 0.96 0.067 0.068
> [98,] 0.97 0.068 0.069
> [99,] 0.98 0.070 0.071
> [100,] 0.99 0.071 0.071
> [101,] 1.00 0.073 0.071
> [102,] 1.01 0.074 0.071
> [103,] 1.02 0.076 0.072
> [104,] 1.03 0.077 0.072
> [105,] 1.04 0.079 0.075
> [106,] 1.05 0.080 0.075
> [107,] 1.06 0.082 0.076
> [108,] 1.07 0.083 0.076
> [109,] 1.08 0.085 0.078
> [110,] 1.09 0.086 0.078
> [111,] 1.10 0.088 0.078
> [112,] 1.11 0.089 0.079
> [113,] 1.12 0.091 0.080
> [114,] 1.13 0.092 0.080
> [115,] 1.14 0.094 0.081
> [116,] 1.15 0.095 0.081
> [117,] 1.16 0.097 0.081
> [118,] 1.17 0.099 0.084
> [119,] 1.18 0.100 0.086
> [120,] 1.19 0.102 0.086
> [121,] 1.20 0.103 0.086
> [122,] 1.21 0.105 0.087
> [123,] 1.22 0.107 0.087
> [124,] 1.23 0.108 0.088
> [125,] 1.24 0.110 0.088
> [126,] 1.25 0.111 0.089
> [127,] 1.26 0.113 0.090
> [128,] 1.27 0.115 0.090
> [129,] 1.28 0.116 0.093
> [130,] 1.29 0.118 0.094
> [131,] 1.30 0.120 0.094
> [132,] 1.31 0.121 0.096
> [133,] 1.32 0.123 0.097
> [134,] 1.33 0.125 0.097
> [135,] 1.34 0.127 0.100
> [136,] 1.35 0.128 0.100
> [137,] 1.36 0.130 0.100
> [138,] 1.37 0.132 0.100
> [139,] 1.38 0.133 0.101
> [140,] 1.39 0.135 0.102
> [141,] 1.40 0.137 0.102
> [142,] 1.41 0.139 0.103
> [143,] 1.42 0.140 0.103
> [144,] 1.43 0.142 0.105
> [145,] 1.44 0.144 0.105
> [146,] 1.45 0.146 0.107
> [147,] 1.46 0.147 0.107
> [148,] 1.47 0.149 0.107
> [149,] 1.48 0.151 0.109
> [150,] 1.49 0.153 0.110
> [151,] 1.50 0.154 0.111
> [152,] 1.51 0.156 0.111
> [153,] 1.52 0.158 0.111
> [154,] 1.53 0.160 0.112
> [155,] 1.54 0.161 0.112
> [156,] 1.55 0.163 0.114
> [157,] 1.56 0.165 0.114
> [158,] 1.57 0.167 0.114
> [159,] 1.58 0.169 0.114
> [160,] 1.59 0.170 0.115
> [161,] 1.60 0.172 0.115
> [162,] 1.61 0.174 0.116
> [163,] 1.62 0.176 0.116
> [164,] 1.63 0.178 0.117
> [165,] 1.64 0.180 0.117
> [166,] 1.65 0.181 0.119
> [167,] 1.66 0.183 0.120
> [168,] 1.67 0.185 0.121
> [169,] 1.68 0.187 0.121
> [170,] 1.69 0.189 0.122
> [171,] 1.70 0.191 0.123
> [172,] 1.71 0.192 0.124
> [173,] 1.72 0.194 0.124
> [174,] 1.73 0.196 0.125
> [175,] 1.74 0.198 0.125
> [176,] 1.75 0.200 0.125
> [177,] 1.76 0.202 0.126
> [178,] 1.77 0.204 0.126
> [179,] 1.78 0.205 0.127
> [180,] 1.79 0.207 0.128
> [181,] 1.80 0.209 0.129
> [182,] 1.81 0.211 0.130
> [183,] 1.82 0.213 0.133
> [184,] 1.83 0.215 0.134
> [185,] 1.84 0.217 0.134
> [186,] 1.85 0.218 0.135
> [187,] 1.86 0.220 0.135
> [188,] 1.87 0.222 0.135
> [189,] 1.88 0.224 0.137
> [190,] 1.89 0.226 0.137
> [191,] 1.90 0.228 0.137
> [192,] 1.91 0.230 0.137
> [193,] 1.92 0.232 0.137
> [194,] 1.93 0.233 0.138
> [195,] 1.94 0.235 0.138
> [196,] 1.95 0.237 0.138
> [197,] 1.96 0.239 0.139
> [198,] 1.97 0.241 0.143
> [199,] 1.98 0.243 0.143
> [200,] 1.99 0.245 0.144
> [201,] 2.00 0.247 0.145
> [202,] 2.01 0.249 0.145
> [203,] 2.02 0.250 0.145
> [204,] 2.03 0.252 0.146
> [205,] 2.04 0.254 0.146
> [206,] 2.05 0.256 0.147
> [207,] 2.06 0.258 0.147
> [208,] 2.07 0.260 0.147
> [209,] 2.08 0.262 0.148
> [210,] 2.09 0.264 0.149
> [211,] 2.10 0.265 0.149
> [212,] 2.11 0.267 0.150
> [213,] 2.12 0.269 0.151
> [214,] 2.13 0.271 0.151
> [215,] 2.14 0.273 0.151
> [216,] 2.15 0.275 0.152
> [217,] 2.16 0.277 0.152
> [218,] 2.17 0.279 0.153
> [219,] 2.18 0.281 0.153
> [220,] 2.19 0.282 0.153
> [221,] 2.20 0.284 0.153
> [222,] 2.21 0.286 0.154
> [223,] 2.22 0.288 0.155
> [224,] 2.23 0.290 0.157
> [225,] 2.24 0.292 0.158
> [226,] 2.25 0.294 0.161
> [227,] 2.26 0.296 0.162
> [228,] 2.27 0.298 0.162
> [229,] 2.28 0.299 0.163
> [230,] 2.29 0.301 0.163
> [231,] 2.30 0.303 0.163
> [232,] 2.31 0.305 0.165
> [233,] 2.32 0.307 0.165
> [234,] 2.33 0.309 0.165
> [235,] 2.34 0.311 0.165
> [236,] 2.35 0.313 0.166
> [237,] 2.36 0.314 0.166
> [238,] 2.37 0.316 0.167
> [239,] 2.38 0.318 0.168
> [240,] 2.39 0.320 0.168
> [241,] 2.40 0.322 0.168
> [242,] 2.41 0.324 0.169
> [243,] 2.42 0.326 0.169
> [244,] 2.43 0.328 0.170
> [245,] 2.44 0.329 0.171
> [246,] 2.45 0.331 0.173
> [247,] 2.46 0.333 0.175
> [248,] 2.47 0.335 0.175
> [249,] 2.48 0.337 0.177
> [250,] 2.49 0.339 0.178
> [251,] 2.50 0.341 0.178
> [252,] 2.51 0.342 0.179
> [253,] 2.52 0.344 0.180
> [254,] 2.53 0.346 0.180
> [255,] 2.54 0.348 0.181
> [256,] 2.55 0.350 0.181
> [257,] 2.56 0.352 0.181
> [258,] 2.57 0.354 0.181
> [259,] 2.58 0.355 0.182
> [260,] 2.59 0.357 0.182
> [261,] 2.60 0.359 0.183
> [262,] 2.61 0.361 0.184
> [263,] 2.62 0.363 0.184
> [264,] 2.63 0.365 0.185
> [265,] 2.64 0.366 0.186
> [266,] 2.65 0.368 0.186
> [267,] 2.66 0.370 0.186
> [268,] 2.67 0.372 0.187
> [269,] 2.68 0.374 0.187
> [270,] 2.69 0.376 0.187
> [271,] 2.70 0.377 0.188
> [272,] 2.71 0.379 0.190
> [273,] 2.72 0.381 0.190
> [274,] 2.73 0.383 0.190
> [275,] 2.74 0.385 0.191
> [276,] 2.75 0.386 0.191
> [277,] 2.76 0.388 0.191
> [278,] 2.77 0.390 0.192
> [279,] 2.78 0.392 0.193
> [280,] 2.79 0.394 0.194
> [281,] 2.80 0.395 0.194
> [282,] 2.81 0.397 0.194
> [283,] 2.82 0.399 0.194
> [284,] 2.83 0.401 0.195
> [285,] 2.84 0.403 0.196
> [286,] 2.85 0.404 0.197
> [287,] 2.86 0.406 0.197
> [288,] 2.87 0.408 0.198
> [289,] 2.88 0.410 0.200
> [290,] 2.89 0.411 0.202
> [291,] 2.90 0.413 0.202
> [292,] 2.91 0.415 0.203
> [293,] 2.92 0.417 0.204
> [294,] 2.93 0.418 0.204
> [295,] 2.94 0.420 0.205
> [296,] 2.95 0.422 0.205
> [297,] 2.96 0.424 0.205
> [298,] 2.97 0.426 0.205
> [299,] 2.98 0.427 0.206
> [300,] 2.99 0.429 0.206
> [301,] 3.00 0.431 0.207
> [302,] 3.01 0.432 0.207
> [303,] 3.02 0.434 0.208
> [304,] 3.03 0.436 0.208
> [305,] 3.04 0.438 0.208
> [306,] 3.05 0.439 0.209
> [307,] 3.06 0.441 0.210
> [308,] 3.07 0.443 0.210
> [309,] 3.08 0.445 0.210
> [310,] 3.09 0.446 0.210
> [311,] 3.10 0.448 0.211
> [312,] 3.11 0.450 0.211
> [313,] 3.12 0.451 0.213
> [314,] 3.13 0.453 0.213
> [315,] 3.14 0.455 0.214
> [316,] 3.15 0.457 0.214
> [317,] 3.16 0.458 0.214
> [318,] 3.17 0.460 0.215
> [319,] 3.18 0.462 0.215
> [320,] 3.19 0.463 0.215
> [321,] 3.20 0.465 0.216
> [322,] 3.21 0.467 0.216
> [323,] 3.22 0.468 0.218
> [324,] 3.23 0.470 0.218
> [325,] 3.24 0.472 0.220
> [326,] 3.25 0.473 0.221
> [327,] 3.26 0.475 0.221
> [328,] 3.27 0.477 0.222
> [329,] 3.28 0.478 0.222
> [330,] 3.29 0.480 0.223
> [331,] 3.30 0.482 0.224
> [332,] 3.31 0.483 0.225
> [333,] 3.32 0.485 0.226
>
> Thank you for your help.
>
>
>
>
> [[alternative HTML version deleted]]
>
>
More information about the R-help
mailing list