0

I have two files in txt format A and B:

File A contains values one below the other (418 values).

The B file contains array values with 17 columns and each column contains 23 values (the values separated by a colon).

I would like to write a code in R that allows:

  1. For file B: copy the columns one below the other to form a single column
  2. The output file: a txt file contains the subtraction result between the column in A file and the resulting column in B file.

This operation will be repeated for several files.

See the attached, File A File B

File A

0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731
0.190148
0.199478
0.20361
0.203169
0.201191
0.201346
0.205708
0.213419
0.221038
0.224394
0.220855
0.210688
0.196785
0.183
0.172166
0.164998
0.160437
0.157072
0.154574
0.154129
0.157576
0.165833
0.177731

File B

0.12878:0.136196:0.135554:0.13608:0.14138:0.174579:0.186398:0.256807:0.254303:0.219796:0.227208:0.204967:0.217935:0.211963:0.175196:0.234157:0.191218
0.128909:0.142429:0.128153:0.139851:0.14249:0.190176:0.173172:0.267493:0.283524:0.23515:0.233571:0.226815:0.2258:0.225029:0.181013:0.253387:0.21417
0.130535:0.142792:0.122401:0.14498:0.142571:0.197696:0.164431:0.258605:0.3002:0.246121:0.231584:0.244324:0.233801:0.230265:0.182308:0.25601:0.232748
0.132557:0.137453:0.120111:0.148618:0.141019:0.197197:0.162695:0.239687:0.302463:0.25137:0.227029:0.250412:0.242177:0.23143:0.180927:0.243387:0.245335
0.133782:0.129703:0.121407:0.148903:0.137579:0.194796:0.167493:0.224874:0.297327:0.252347:0.226346:0.243601:0.250463:0.234913:0.181163:0.222744:0.252813
0.133883:0.124062:0.125157:0.146549:0.133007:0.198916:0.176677:0.224186:0.295805:0.252501:0.232605:0.229474:0.257644:0.24504:0.187161:0.203275:0.256944
0.133738:0.123672:0.13:0.144836:0.129141:0.214668:0.188191:0.237392:0.305372:0.255212:0.243695:0.217807:0.262611:0.260563:0.200071:0.191577:0.258495
0.13489:0.128566:0.135226:0.147825:0.128186:0.23988:0.201013:0.254229:0.324588:0.261613:0.253778:0.216927:0.264611:0.274689:0.216733:0.188945:0.256424
0.138422:0.13581:0.140907:0.157792:0.131518:0.265395:0.214716:0.260835:0.343394:0.269626:0.257002:0.228643:0.263419:0.278806:0.230844:0.191816:0.248697
0.144008:0.141377:0.147269:0.173429:0.138692:0.279672:0.228195:0.248381:0.349008:0.274851:0.251085:0.246887:0.259188:0.267688:0.236057:0.194759:0.23416
0.149777:0.142563:0.153848:0.190008:0.147321:0.27507:0.238757:0.218545:0.333822:0.272862:0.238535:0.260955:0.252151:0.242955:0.229285:0.193948:0.214135
0.153174:0.139434:0.159126:0.201527:0.154004:0.2521:0.242587:0.182511:0.300373:0.261612:0.224813:0.261504:0.242456:0.212605:0.212324:0.189:0.192544
0.15235:0.134484:0.161055:0.203679:0.15589:0.219132:0.236615:0.154233:0.260276:0.242596:0.214732:0.245761:0.230295:0.186826:0.190876:0.182248:0.174302
0.147261:0.130802:0.15823:0.195977:0.152049:0.187795:0.220738:0.142276:0.227748:0.220157:0.20947:0.218908:0.216253:0.172579:0.171592:0.176303:0.162867
0.139791:0.129989:0.15099:0.181827:0.143921:0.166847:0.198906:0.145349:0.211713:0.199398:0.206162:0.190962:0.201627:0.170219:0.158879:0.171807:0.158443
0.132815:0.13121:0.141672:0.166588:0.134591:0.158168:0.178091:0.154223:0.211335:0.183958:0.200311:0.17116:0.18839:0.174108:0.153269:0.16706:0.158012
0.128714:0.131951:0.133723:0.154791:0.127314:0.157074:0.165383:0.158593:0.21762:0.174877:0.189412:0.163308:0.178726:0.17672:0.152134:0.159819:0.157265
0.12821:0.129966:0.130053:0.14813:0.124088:0.156469:0.164655:0.154331:0.219932:0.171062:0.175343:0.164776:0.174282:0.173591:0.152063:0.149945:0.153328
0.130179:0.125075:0.131543:0.145311:0.125005:0.151968:0.174619:0.146359:0.213176:0.170823:0.163854:0.169456:0.175521:0.166022:0.151281:0.140906:0.146654
0.132495:0.119582:0.136567:0.143624:0.12863:0.1447:0.189405:0.145254:0.20108:0.17335:0.161328:0.172495:0.181538:0.159918:0.150548:0.13875:0.140927
0.133362:0.11696:0.141827:0.141094:0.133035:0.14009:0.201427:0.159803:0.193559:0.179141:0.170805:0.173606:0.190467:0.161648:0.152118:0.148839:0.141013
0.132306:0.119608:0.144067:0.137789:0.136824:0.143631:0.205018:0.190363:0.199934:0.189145:0.189764:0.176801:0.200277:0.173668:0.157592:0.172201:0.150168
0.130263:0.127115:0.141712:0.135491:0.139544:0.156582:0.198918:0.227473:0.222448:0.203333:0.211166:0.186848:0.209566:0.192753:0.166266:0.203816:0.168137
valkyrie
  • 1
  • 1

1 Answers1

1
require(dplyr)
a <- read.table("a.txt", header =F) %>% unlist(.) %>% as.numeric()
b <- read.table("b.txt", header = F) %>% unlist(.) %>% as.numeric()
a - b
jeffverboon
  • 326
  • 1
  • 4