Incontinuous Quaternion Signals - r

I'm using a BNO055 IMU and I sometimes see "jumps" in the quaternion signals during the movement. Is this normal? Here's a sample plot.
The first plot is the scalar value and the rest are the three vector components.
I assumed this happens to Euler Angles but not in Quaternions. Is there something I'm missing?
0.4978 0.37885 0.65814 -0.41888
0.49774 0.37854 0.65778 -0.41986
0.49762 0.37842 0.65759 -0.42035
0.49878 0.37616 0.6582 -0.42017
0.49878 0.37561 0.65784 -0.42114
0.49872 0.37537 0.65765 -0.42175
0.49933 0.3736 0.65802 -0.42206
0.49902 0.37347 0.65753 -0.42328
0.49896 0.37335 0.65735 -0.42371
0.49921 0.37189 0.6579 -0.42383
0.49872 0.37164 0.65771 -0.42499
0.49841 0.37158 0.65784 -0.42517
0.49854 0.37042 0.65881 -0.42444
0.49792 0.37042 0.65936 -0.42444
0.4975 0.37048 0.65961 -0.42456
0.49768 0.36932 0.66034 -0.42413
0.49701 0.36957 0.66034 -0.42468
0.49664 0.36975 0.66022 -0.42511
0.49719 0.36823 0.66083 -0.42487
0.49658 0.36877 0.66028 -0.42596
0.49622 0.36908 0.65991 -0.42664
0.49683 0.3678 0.66034 -0.42645
0.49609 0.36841 0.65973 -0.42767
0.49573 0.36871 0.65948 -0.42822
0.49658 0.36713 0.66003 -0.42773
0.49591 0.36768 0.65948 -0.42889
0.49554 0.36798 0.65918 -0.4295
0.49658 0.36572 0.66016 -0.42877
0.49554 0.36639 0.65942 -0.43048
0.49493 0.36676 0.659 -0.43158
0.49426 0.36682 0.65857 -0.43292
0.49316 0.36774 0.65765 -0.43475
0.49274 0.36816 0.65723 -0.43555
0.49261 0.36768 0.65717 -0.43616
0.49188 0.3681 0.65662 -0.43744
0.49152 0.36829 0.65643 -0.43805
0.4917 0.36719 0.65662 -0.43842
0.49091 0.36749 0.65619 -0.43976
0.49048 0.36768 0.65594 -0.44043
0.4903 0.36707 0.65607 -0.44098
0.48956 0.36713 0.65582 -0.44208
0.48926 0.36707 0.65576 -0.44257
0.48944 0.36591 0.65619 -0.44263
0.48926 0.36542 0.65631 -0.44312
0.48914 0.36511 0.65649 -0.44324
0.48962 0.36328 0.65741 -0.44281
0.48956 0.3623 0.6579 -0.44293
0.48956 0.36176 0.6582 -0.44299
0.4903 0.35937 0.65936 -0.44238
0.48993 0.35846 0.65967 -0.44305
0.48969 0.35815 0.65979 -0.44348
0.4903 0.35614 0.66077 -0.44287
0.48975 0.35596 0.66095 -0.44336
0.48956 0.35583 0.66101 -0.44354
0.48999 0.35449 0.66168 -0.44312
0.48969 0.35437 0.66174 -0.4436
0.48944 0.35431 0.66174 -0.44385
0.48932 0.35382 0.66193 -0.44409
0.48907 0.35364 0.66199 -0.44446
0.48895 0.35358 0.66199 -0.44464
0.48914 0.35272 0.66211 -0.44482
0.48883 0.35284 0.66193 -0.44543
0.48865 0.35297 0.6618 -0.4458
0.48938 0.35162 0.66229 -0.44519
0.48914 0.35193 0.66205 -0.44562
0.48901 0.35205 0.66199 -0.44574
0.48993 0.35059 0.66278 -0.44476
0.48999 0.35028 0.66309 -0.44446
0.49011 0.3501 0.66321 -0.44427
0.49097 0.34845 0.66425 -0.44305
0.49103 0.34814 0.66467 -0.44263
0.49103 0.34802 0.66486 -0.44238
0.49133 0.34747 0.66553 -0.44153
0.49152 0.34711 0.66608 -0.4408
0.49164 0.34686 0.66638 -0.44037
0.49274 0.34515 0.66766 -0.43854
0.49286 0.34473 0.66827 -0.43781
0.49298 0.34448 0.66858 -0.43744
0.49408 0.34259 0.66998 -0.43549
0.49445 0.34204 0.67065 -0.43451
0.49457 0.34174 0.67102 -0.43402
0.49518 0.34064 0.67194 -0.43274
0.49536 0.34015 0.67249 -0.43213
0.49536 0.3399 0.67273 -0.43188
0.49652 0.33789 0.67395 -0.43024
0.49652 0.33771 0.67426 -0.42987
0.49652 0.33765 0.67438 -0.42969
0.49738 0.33612 0.67535 -0.42834
0.49738 0.336 0.67566 -0.42804
0.49744 0.33588 0.67572 -0.42792
0.49835 0.33429 0.6767 -0.42664
0.49829 0.33423 0.67688 -0.42645
0.49829 0.33423 0.67694 -0.42633
0.49902 0.33276 0.67767 -0.42542
0.4989 0.3327 0.67767 -0.4256
0.49878 0.3327 0.67767 -0.42572
0.49908 0.33197 0.6781 -0.42535
0.49884 0.33209 0.67798 -0.42572
0.49872 0.33221 0.67786 -0.4259
0.49847 0.33228 0.67786 -0.42615
0.49835 0.3324 0.67786 -0.42627
0.49817 0.33252 0.67773 -0.42664
0.4986 0.33179 0.67798 -0.42627
0.49847 0.33185 0.67786 -0.42651
0.49823 0.33191 0.67773 -0.42694
0.4986 0.33105 0.67804 -0.4267
0.49854 0.33112 0.67798 -0.42682
0.49835 0.3313 0.67773 -0.42725
0.49829 0.33112 0.67767 -0.42761
0.49811 0.33118 0.67755 -0.42792
0.49786 0.33118 0.67743 -0.42841
0.49872 0.32953 0.6781 -0.42761
0.49866 0.32947 0.67804 -0.4278
0.49847 0.32947 0.67804 -0.42804
0.49847 0.32922 0.6781 -0.4281
0.49847 0.32922 0.67816 -0.42816
0.49841 0.32898 0.67822 -0.4281
0.49957 0.32697 0.67914 -0.42694
0.49957 0.32684 0.6792 -0.42694
0.49957 0.3266 0.67938 -0.42682
0.50031 0.32544 0.67993 -0.4259
0.50037 0.32532 0.68005 -0.42578
0.50049 0.32495 0.6803 -0.4256
0.50159 0.32306 0.68121 -0.42426
0.50165 0.32288 0.68127 -0.42413
0.50183 0.32251 0.68146 -0.42401
0.50256 0.32129 0.68207 -0.4231
0.50262 0.32117 0.68213 -0.42303
0.50269 0.32092 0.68219 -0.42291
0.50281 0.3208 0.68213 -0.42297
0.50287 0.32074 0.68213 -0.42303
0.50293 0.32068 0.68201 -0.42322
0.50323 0.32019 0.68207 -0.4231
0.50323 0.32019 0.68195 -0.42328
0.50323 0.32025 0.68182 -0.42346
0.50385 0.31934 0.68213 -0.42291
0.50385 0.31934 0.68207 -0.42303
0.50391 0.31934 0.68188 -0.42322
0.50513 0.31738 0.68268 -0.42194
0.50519 0.31738 0.68262 -0.42206
0.50513 0.31744 0.6825 -0.42218
0.50537 0.31708 0.68262 -0.42206
0.50537 0.31714 0.68256 -0.42212
0.50543 0.31708 0.6825 -0.42212
0.50629 0.31567 0.68311 -0.4212
0.50629 0.31567 0.68311 -0.4212
0.50629 0.31567 0.68304 -0.4212
0.50684 0.31482 0.68347 -0.42059
0.50696 0.31458 0.68359 -0.42035
0.50702 0.31451 0.68365 -0.42029
0.50757 0.3136 0.68402 -0.41974
0.50757 0.3136 0.68396 -0.41974
0.50763 0.3136 0.68396 -0.41974
0.50806 0.31287 0.68427 -0.41925
0.50806 0.31281 0.68427 -0.41925
0.50812 0.31281 0.68427 -0.41931
0.50867 0.31183 0.68469 -0.41858
0.50873 0.31183 0.68469 -0.41858
0.50873 0.31183 0.68469 -0.41858
0.50916 0.31104 0.685 -0.41803
0.50922 0.31104 0.685 -0.41803
0.50922 0.31104 0.685 -0.41803
0.51013 0.30957 0.68561 -0.41699
0.51013 0.30957 0.68561 -0.41699
0.51013 0.30957 0.68561 -0.41699
0.51044 0.30902 0.68579 -0.41663
0.51044 0.30902 0.68579 -0.41669
0.51044 0.30902 0.68579 -0.41669
0.51111 0.30792 0.68628 -0.41589
0.51117 0.30792 0.68622 -0.41589
0.51135 0.30768 0.68628 -0.41577
0.51135 0.30768 0.68628 -0.41577
0.51135 0.30762 0.68622 -0.41583
0.51208 0.3064 0.68677 -0.41498
0.51208 0.3064 0.68677 -0.41498
0.51215 0.30627 0.68683 -0.41492
0.51312 0.30463 0.68756 -0.4137
0.51324 0.3045 0.68756 -0.41364
0.51324 0.3045 0.68756 -0.41364
0.51385 0.30341 0.68799 -0.4129
0.51392 0.30341 0.68799 -0.41296
0.51392 0.30334 0.68799 -0.41296
0.51428 0.3028 0.68811 -0.41266
0.51434 0.30273 0.68805 -0.41272
0.51483 0.302 0.68835 -0.41223
0.51483 0.302 0.68835 -0.41223
0.51483 0.30194 0.68835 -0.41229
0.51495 0.30176 0.68842 -0.41217
0.51501 0.3017 0.68835 -0.41217
0.51501 0.3017 0.68835 -0.41223
0.51526 0.30139 0.68842 -0.41211
0.51526 0.30133 0.68842 -0.41211
0.51526 0.30133 0.68835 -0.41211
0.51593 0.30023 0.68872 -0.41144
0.51593 0.30023 0.68872 -0.41144
0.51611 0.29999 0.68878 -0.41132
0.51617 0.29987 0.68872 -0.41144
0.51617 0.29993 0.6886 -0.41162
0.51691 0.29865 0.68903 -0.41095
0.51691 0.29858 0.68896 -0.41101
0.51691 0.29846 0.68896 -0.41113
0.51703 0.29834 0.68884 -0.41125
0.51715 0.29822 0.68872 -0.41138
0.51721 0.2981 0.68872 -0.41144
0.51746 0.29767 0.68878 -0.41138
0.51752 0.29742 0.68878 -0.41144
0.51746 0.29761 0.6886 -0.41174
0.51752 0.29761 0.68854 -0.4118
0.51752 0.29761 0.68854 -0.4118
0.51776 0.2973 0.68854 -0.41162
0.51776 0.2973 0.68854 -0.41162
0.51776 0.2973 0.68854 -0.41162
0.5177 0.29736 0.68848 -0.41174
0.5177 0.2973 0.68848 -0.4118
0.51776 0.29724 0.68842 -0.41187
0.51831 0.29633 0.68872 -0.41138
0.51837 0.29639 0.68866 -0.41144
0.51831 0.29639 0.68854 -0.41156
0.51874 0.29559 0.68884 -0.41119
0.51874 0.29547 0.68884 -0.41125
0.51892 0.29517 0.68878 -0.41125
0.51898 0.29504 0.68878 -0.41132
0.51923 0.2948 0.68854 -0.41156
0.51959 0.29443 0.68829 -0.4118
0.52008 0.2937 0.68835 -0.41156
0.52032 0.29352 0.68799 -0.41205
0.52032 0.2937 0.68726 -0.41315
0.52045 0.2937 0.68695 -0.41351
0.52051 0.29388 0.68616 -0.41455
0.52063 0.2937 0.68585 -0.41504
0.52112 0.29291 0.68518 -0.41608
0.52179 0.29218 0.68427 -0.41736
0.52252 0.29144 0.68317 -0.4187
0.52313 0.29077 0.68274 -0.41913
0.5238 0.29041 0.68152 -0.42053
0.52417 0.29016 0.68103 -0.42102
0.52472 0.28906 0.68085 -0.42133
0.52545 0.28772 0.68066 -0.42163
0.52637 0.28619 0.68048 -0.42187
0.52692 0.2854 0.68036 -0.42194
0.52808 0.28381 0.67999 -0.42212
0.5293 0.28247 0.67957 -0.42224
0.52997 0.2818 0.67926 -0.42224
0.53107 0.28058 0.67908 -0.422
0.53223 0.27924 0.67908 -0.42151
0.53296 0.27838 0.67902 -0.42126
0.53479 0.27637 0.67871 -0.42065
0.53583 0.27521 0.67853 -0.42035
0.53796 0.27264 0.67828 -0.41974
0.53998 0.27008 0.67816 -0.41907
0.54102 0.26874 0.67816 -0.41852
0.54321 0.26575 0.67834 -0.4173
0.54559 0.26257 0.67853 -0.41589
0.54687 0.26099 0.67853 -0.41522
0.54944 0.25824 0.6781 -0.41425
0.55151 0.25665 0.67694 -0.41437
0.55225 0.25641 0.67615 -0.41479
0.55341 0.25647 0.67456 -0.41583
0.55475 0.25623 0.67291 -0.41687
0.55554 0.25574 0.67224 -0.41718
0.55768 0.25403 0.67126 -0.41699
0.56042 0.25128 0.67096 -0.41547
0.56183 0.24976 0.67078 -0.41473
0.56439 0.24719 0.67017 -0.41382
0.56616 0.24554 0.66949 -0.41351
0.56683 0.24518 0.66901 -0.41357
0.56769 0.24554 0.6676 -0.41443
0.56818 0.24713 0.66547 -0.41626
0.56836 0.24817 0.66418 -0.41742
0.56854 0.25073 0.66156 -0.41974
0.56873 0.25354 0.65955 -0.42108
0.56891 0.25476 0.65875 -0.42126
0.5697 0.25684 0.65747 -0.42096
0.57098 0.25903 0.6557 -0.42065
0.57178 0.26038 0.65442 -0.42078
0.57239 0.26373 0.65234 -0.42102
0.57269 0.26721 0.65015 -0.42181
0.57275 0.26843 0.64923 -0.42236
0.57288 0.26941 0.64801 -0.42346
0.57306 0.26898 0.64758 -0.42413
0.57312 0.26855 0.64746 -0.42444
0.57184 0.27045 0.6463 -0.42676
0.57355 0.26825 0.64636 -0.42584
0.57391 0.26746 0.64661 -0.42542
0.57349 0.26819 0.64587 -0.42664
0.57361 0.2691 0.64459 -0.4278
0.57397 0.26953 0.64362 -0.42859
0.57294 0.27289 0.64032 -0.43274
0.573 0.27423 0.63849 -0.43457
0.573 0.27484 0.63757 -0.43542
0.5708 0.27911 0.6347 -0.43976
0.57092 0.27991 0.63336 -0.44098
0.57111 0.28027 0.63251 -0.44177
0.56897 0.28424 0.62958 -0.44623
0.56915 0.284 0.62891 -0.44708
0.56927 0.28369 0.62878 -0.44727
0.56726 0.28619 0.62744 -0.4502
0.56763 0.28564 0.62714 -0.45044
0.56805 0.28503 0.62701 -0.45044
0.5675 0.2854 0.6261 -0.45227
0.56848 0.28333 0.62604 -0.45239
0.56866 0.28247 0.62616 -0.45251
0.56769 0.28217 0.62659 -0.45337
0.56726 0.28119 0.6283 -0.45215
0.56708 0.2807 0.62885 -0.45184
0.56567 0.28143 0.62878 -0.45325
0.56604 0.27985 0.62964 -0.45251
0.56616 0.27917 0.63025 -0.45203
0.56543 0.27887 0.63123 -0.45172
0.56567 0.27686 0.63306 -0.45013
0.56598 0.27563 0.63379 -0.44946
0.5658 0.27448 0.6344 -0.44946
0.56628 0.2724 0.63611 -0.44781
0.56659 0.27118 0.63727 -0.44653
0.56708 0.26874 0.63953 -0.44403
0.56818 0.26556 0.64203 -0.44092
0.56873 0.2641 0.64325 -0.43933
0.56915 0.26257 0.64496 -0.43726
0.57025 0.26038 0.64691 -0.43414
0.57074 0.25952 0.64783 -0.43268
0.57086 0.25867 0.64954 -0.43048
0.57135 0.25714 0.65149 -0.4278
0.57159 0.25653 0.6524 -0.42651
0.57104 0.2569 0.65356 -0.42517
0.57129 0.25616 0.65564 -0.42206
0.57141 0.25586 0.65692 -0.4201
0.57159 0.25543 0.65936 -0.41626
0.5719 0.2547 0.66162 -0.41272
0.57196 0.25446 0.6626 -0.41119
0.57208 0.25403 0.66449 -0.40826
0.57214 0.25354 0.66687 -0.40454
0.57208 0.25342 0.66809 -0.40271
0.57062 0.25488 0.66968 -0.40125
0.56921 0.25592 0.67133 -0.39978
0.5683 0.25677 0.67206 -0.39935
0.56525 0.2616 0.67236 -0.40002
0.56299 0.26532 0.67297 -0.39978
0.56158 0.26733 0.67297 -0.40033
0.55786 0.27264 0.67212 -0.40338
0.55432 0.27722 0.67145 -0.40631
0.55249 0.27942 0.67126 -0.40759
0.54889 0.28461 0.66992 -0.41101
0.54651 0.2879 0.66919 -0.41315
0.5451 0.28949 0.66895 -0.41418
0.54254 0.29254 0.66864 -0.41595
0.54034 0.29553 0.66833 -0.41718
0.53931 0.29736 0.66791 -0.41791
0.53687 0.30176 0.66681 -0.41962
0.53387 0.30634 0.66577 -0.42175
0.5321 0.30859 0.66534 -0.42303
0.52856 0.31238 0.66473 -0.4256
0.52563 0.31519 0.66443 -0.42761
0.5246 0.31622 0.66443 -0.42816
0.52313 0.31769 0.66486 -0.42828
0.52216 0.31873 0.66565 -0.42743
0.52179 0.31909 0.6662 -0.42676
0.52112 0.31976 0.6673 -0.42529
0.52039 0.3205 0.66827 -0.42419
0.51996 0.32104 0.66852 -0.42389
0.51874 0.32245 0.66882 -0.42383
0.51733 0.32391 0.6687 -0.4245
0.51666 0.32471 0.66858 -0.42505
0.5152 0.32599 0.66833 -0.42609
0.51385 0.32715 0.66827 -0.42706
0.51324 0.32745 0.66833 -0.42743
0.51227 0.32776 0.6687 -0.4278
0.5116 0.32776 0.66925 -0.42767
0.51141 0.3277 0.66956 -0.42761
0.51093 0.32733 0.6701 -0.42743
0.51031 0.32709 0.67065 -0.42755
0.51001 0.32709 0.67084 -0.42773
0.50909 0.32733 0.67096 -0.42841
0.508 0.32782 0.6709 -0.42938
0.50745 0.32794 0.67084 -0.43005
0.50702 0.32733 0.67114 -0.43054
0.50604 0.32776 0.6712 -0.43127
0.50562 0.32794 0.67126 -0.43152
0.50586 0.32654 0.67224 -0.43079
0.50562 0.32642 0.67224 -0.43115
0.50537 0.32629 0.67242 -0.43127
0.50549 0.32495 0.67322 -0.43097
0.50488 0.32428 0.67389 -0.43109
0.50452 0.32391 0.67426 -0.43121
0.50439 0.32184 0.67542 -0.43109
0.50311 0.32098 0.67566 -0.43286
0.50238 0.32056 0.67554 -0.43414
0.50183 0.31818 0.67548 -0.43658
0.50055 0.31628 0.67438 -0.44116
0.49969 0.31531 0.67346 -0.44421
0.49823 0.31213 0.67163 -0.45087
0.49438 0.31024 0.66888 -0.46033
0.49249 0.30884 0.66748 -0.46533
0.48987 0.3031 0.66595 -0.47394
0.48523 0.29797 0.66522 -0.48297
0.48248 0.29517 0.66498 -0.48773
0.47675 0.28815 0.66461 -0.49799
0.46942 0.28113 0.66376 -0.50995
0.46552 0.27704 0.66351 -0.51599
0.45862 0.26611 0.66443 -0.52661
0.45184 0.25269 0.66528 -0.53796
0.44836 0.24542 0.66553 -0.54382
0.44214 0.23041 0.66595 -0.55487
0.43695 0.21545 0.66516 -0.56586
0.43469 0.20819 0.66406 -0.57159
0.43048 0.19226 0.66223 -0.5824
0.42621 0.1734 0.6618 -0.59186
0.42346 0.16333 0.66248 -0.59595
0.41821 0.14209 0.66461 -0.60266
0.41278 0.11896 0.66742 -0.60834
0.40973 0.10706 0.66864 -0.61127
0.4032 0.08392 0.67041 -0.61719
0.396 0.06049 0.67145 -0.62341
0.39233 0.04865 0.67187 -0.62628
0.38403 0.02545 0.67358 -0.63098
0.37476 0.00323 0.67542 -0.63513
0.37018 -0.00739 0.67584 -0.63733
0.36084 -0.02777 0.67633 -0.64154
0.3512 -0.04767 0.67682 -0.6452
0.34644 -0.05725 0.67688 -0.64691
0.33783 -0.07623 0.67627 -0.65015
0.32916 -0.09412 0.6756 -0.65295
0.32483 -0.10278 0.67523 -0.65417
0.31628 -0.11951 0.67438 -0.65643
0.30859 -0.13525 0.67346 -0.65796
0.30524 -0.14301 0.67303 -0.65839
0.29883 -0.15735 0.67212 -0.65894
0.29285 -0.17017 0.67084 -0.65973
0.29016 -0.17627 0.67004 -0.6601
0.28577 -0.18774 0.66852 -0.66046
0.28168 -0.19818 0.6673 -0.6604
0.2796 -0.20319 0.66681 -0.66022
0.27612 -0.21216 0.66632 -0.65936
0.27332 -0.21948 0.66602 -0.65845
0.27197 -0.22217 0.66595 -0.65814
0.26971 -0.22528 0.66638 -0.65759
0.26965 -0.2262 0.66724 -0.65643
0.27045 -0.22577 0.66772 -0.65576
0.27319 -0.22284 0.66895 -0.65442
0.27765 -0.21875 0.67047 -0.65234
0.28021 -0.216 0.6712 -0.65137
0.28564 -0.20801 0.67273 -0.65009
0.29242 -0.19879 0.67462 -0.64801
0.29602 -0.19415 0.6756 -0.64667
0.30304 -0.18378 0.67767 -0.64435
0.31012 -0.17163 0.67938 -0.64252
0.31396 -0.16516 0.67981 -0.64191
0.32214 -0.15137 0.68018 -0.64081
0.33002 -0.13611 0.68066 -0.63971
0.33392 -0.12799 0.68103 -0.63898
0.34253 -0.11212 0.68109 -0.63739
0.35144 -0.0957 0.6795 -0.6369
0.35565 -0.0871 0.67853 -0.63678
0.36462 -0.06873 0.67621 -0.63641
0.37415 -0.05145 0.6734 -0.63556
0.37714 -0.04175 0.67322 -0.6347
0.38361 -0.02252 0.67169 -0.63336
0.3913 -0.0036 0.66858 -0.63239
0.39618 0.0047 0.66656 -0.63141
0.40436 0.02069 0.66473 -0.62781
0.40839 0.04364 0.66541 -0.62329
0.40979 0.05762 0.66559 -0.62103
0.41833 0.08002 0.66089 -0.61792
0.42279 0.09088 0.65839 -0.61603
0.42828 0.11566 0.65662 -0.60992
0.42963 0.14301 0.65747 -0.60223
0.42999 0.1557 0.65765 -0.59863
0.43103 0.17578 0.65833 -0.59155
0.43188 0.19214 0.66113 -0.58264
0.43396 0.19739 0.6629 -0.57733
0.44061 0.20557 0.66614 -0.56561
0.44531 0.21387 0.66895 -0.55536
0.44952 0.2215 0.6712 -0.54626
0.45117 0.22516 0.6723 -0.54199
0.45361 0.23413 0.67395 -0.53406
0.45398 0.23975 0.67493 -0.52997
0.45251 0.25287 0.67804 -0.52112
0.4516 0.26282 0.68158 -0.51227
0.45349 0.2652 0.68262 -0.508
0.45825 0.26947 0.68335 -0.50043
0.46191 0.27368 0.68396 -0.49396
0.46289 0.27582 0.68439 -0.49121
0.46259 0.28119 0.68542 -0.48694
0.46167 0.2887 0.68579 -0.48291
0.46191 0.29266 0.68524 -0.48108
0.46417 0.29999 0.68231 -0.47858
0.46539 0.30841 0.67859 -0.47729
0.46466 0.31329 0.67706 -0.47693
0.46198 0.32349 0.67401 -0.47711
0.46185 0.32941 0.6712 -0.47711
0.46277 0.33087 0.67059 -0.47614
0.46405 0.33325 0.67102 -0.4726
0.46539 0.33508 0.67358 -0.46625
0.46698 0.33557 0.67523 -0.46191
0.47168 0.33514 0.67834 -0.45276
0.47717 0.33417 0.67969 -0.44568
0.47937 0.33356 0.68011 -0.44318
0.48199 0.33136 0.68127 -0.44019
0.48431 0.32794 0.68188 -0.43927
0.48547 0.32648 0.68182 -0.43921
0.4873 0.32458 0.68134 -0.43921
0.48773 0.32434 0.68109 -0.43939
0.48767 0.32446 0.68085 -0.4397
0.48846 0.32416 0.68005 -0.44025
0.48926 0.32361 0.67963 -0.44049
0.48975 0.32312 0.6795 -0.44043
0.49103 0.32172 0.67944 -0.44019
0.49237 0.32007 0.67926 -0.44012
0.49292 0.31934 0.67914 -0.44025
0.49414 0.31812 0.67834 -0.44104
0.49463 0.31793 0.67725 -0.4422
0.49487 0.31805 0.6767 -0.44275
0.49548 0.31818 0.6756 -0.4436
0.49634 0.31781 0.67487 -0.44415
0.49689 0.31726 0.67462 -0.44421
0.49805 0.31561 0.67462 -0.44403
0.49921 0.31378 0.6748 -0.44379
0.49988 0.31293 0.67487 -0.4436
0.50128 0.31134 0.6748 -0.44324
0.50238 0.31042 0.67444 -0.44318
0.50281 0.31012 0.67426 -0.44318
0.50348 0.30969 0.67389 -0.44324
0.50397 0.30939 0.67352 -0.44354
0.50415 0.3092 0.67334 -0.44373
0.50458 0.30896 0.67273 -0.44427
0.50531 0.30853 0.67187 -0.44501
0.50568 0.30835 0.67163 -0.44513
0.50665 0.30762 0.67084 -0.44574
0.50751 0.30713 0.66956 -0.44702
0.50793 0.30707 0.66858 -0.44806
0.50867 0.30731 0.66608 -0.45074
0.50909 0.30829 0.66278 -0.45441
0.50934 0.30872 0.66083 -0.45667
0.51007 0.30908 0.65643 -0.46198
0.51038 0.30896 0.65222 -0.46765
0.51031 0.30878 0.65045 -0.47028
0.5105 0.30786 0.64771 -0.47449
0.51129 0.30621 0.64624 -0.47662
0.51196 0.30518 0.646 -0.47693
0.51349 0.30286 0.6463 -0.47632
0.51569 0.29968 0.64752 -0.4743
0.51691 0.29779 0.64844 -0.4729
0.51953 0.29352 0.65094 -0.4693
0.52081 0.29114 0.65253 -0.4671
0.52386 0.2854 0.65594 -0.46246
0.52765 0.2793 0.65869 -0.45801
0.5296 0.27655 0.65936 -0.45636
0.53345 0.27191 0.65955 -0.45441
0.53693 0.26782 0.65869 -0.45392
0.53857 0.26581 0.65796 -0.45435
0.54034 0.26263 0.6571 -0.45526
0.54236 0.26007 0.65692 -0.45453
0.54352 0.25946 0.65674 -0.45386
0.54492 0.26013 0.65503 -0.45422
0.5448 0.26294 0.65216 -0.45685
0.54395 0.26538 0.65045 -0.45892
0.54181 0.2713 0.64679 -0.46313
0.5401 0.27765 0.64331 -0.46619
0.53973 0.28064 0.64154 -0.46722
0.53998 0.2865 0.63739 -0.46912
0.53943 0.29291 0.63324 -0.47137
0.53857 0.29663 0.63116 -0.4729
0.53644 0.30487 0.62622 -0.4765
0.53375 0.31268 0.62103 -0.48126
0.53174 0.31659 0.61926 -0.48328
0.52832 0.32239 0.61633 -0.48694
0.52606 0.32477 0.61389 -0.49084
0.52527 0.32562 0.61298 -0.49231
0.52478 0.32556 0.61182 -0.49432
0.52557 0.3244 0.61115 -0.49506
0.52643 0.32336 0.61121 -0.49469
0.52979 0.32007 0.6106 -0.49402
0.53363 0.31647 0.60901 -0.49414
0.53546 0.31506 0.60791 -0.49445
0.53809 0.31287 0.6059 -0.49542
0.53998 0.31116 0.60388 -0.49695
0.54065 0.31055 0.60284 -0.4978
0.54126 0.31018 0.60059 -0.50012
0.54132 0.31097 0.59772 -0.50299
0.5412 0.31158 0.5965 -0.50427
0.54089 0.31238 0.59497 -0.5058
0.54059 0.31262 0.59424 -0.50684
0.54053 0.31268 0.59393 -0.5072
0.54102 0.31238 0.59332 -0.50769
0.54187 0.31134 0.59344 -0.50726
0.54242 0.31055 0.59369 -0.5069
0.54327 0.3092 0.59387 -0.50653
0.54382 0.3078 0.59467 -0.50586
0.54407 0.30707 0.59546 -0.50513
0.54456 0.30591 0.59686 -0.50366
0.54474 0.30518 0.59827 -0.5022
0.54468 0.30505 0.59924 -0.50122
0.54431 0.30499 0.60114 -0.49933
0.54395 0.3053 0.6026 -0.4978
0.54382 0.30542 0.60333 -0.49701
0.54352 0.30518 0.60541 -0.49493
0.5434 0.30499 0.60779 -0.49219
0.54352 0.30481 0.60889 -0.49084
0.54382 0.30444 0.61047 -0.48883
0.54395 0.30396 0.61163 -0.48755
0.54395 0.30383 0.6123 -0.48669
0.54431 0.30328 0.61456 -0.48376
0.54456 0.3028 0.61694 -0.48083
0.54449 0.3028 0.61761 -0.47992
0.54456 0.30292 0.61847 -0.47876
0.54456 0.30292 0.6192 -0.47772
0.54431 0.30273 0.62177 -0.47485
0.54413 0.3028 0.62378 -0.47235
0.54437 0.30267 0.62445 -0.47131
0.54523 0.30194 0.62592 -0.46881
0.54602 0.30078 0.62866 -0.46497
0.5462 0.30011 0.63055 -0.46265
0.54669 0.29919 0.63403 -0.45782
0.54767 0.29803 0.63696 -0.45343
0.5481 0.29718 0.63843 -0.45129
0.54889 0.29541 0.64142 -0.44727
0.54907 0.29413 0.64478 -0.44305
0.54895 0.29395 0.6463 -0.4411
0.54846 0.29443 0.6485 -0.43811
0.54724 0.29608 0.65027 -0.43591
0.54657 0.29706 0.651 -0.435
0.54523 0.29938 0.6521 -0.43341
0.54327 0.3017 0.65265 -0.43347
0.54144 0.30365 0.6535 -0.43317
0.53717 0.30774 0.65515 -0.43298
0.53357 0.31134 0.65625 -0.43329
0.53217 0.31281 0.65668 -0.43323
0.52972 0.31543 0.65796 -0.43243
0.52795 0.31738 0.65924 -0.43115
0.52722 0.31805 0.65997 -0.43048
0.52612 0.31873 0.66138 -0.42926
0.52545 0.3186 0.6626 -0.42822
0.52527 0.31836 0.66321 -0.42761
0.5249 0.31769 0.66467 -0.42633
0.52429 0.31726 0.66595 -0.42542
0.5238 0.31732 0.66644 -0.42523
0.52258 0.31763 0.66693 -0.4256
0.52136 0.31812 0.66742 -0.42609
0.52081 0.31836 0.66766 -0.42609
0.5199 0.31879 0.66864 -0.42542
0.5188 0.31927 0.66962 -0.4248
0.51819 0.31964 0.67004 -0.42474
0.51691 0.32043 0.67041 -0.42511
0.5155 0.32196 0.67017 -0.42603
0.51465 0.323 0.66992 -0.42664
0.51276 0.32538 0.66931 -0.42804
0.51068 0.32758 0.66882 -0.42957
0.50964 0.32849 0.66876 -0.4303
0.50793 0.32996 0.66876 -0.43115
0.50677 0.33093 0.66895 -0.43152
0.50629 0.33136 0.66907 -0.43158
0.50537 0.33209 0.66937 -0.43158
0.50452 0.33276 0.6698 -0.43146
0.50409 0.33307 0.66998 -0.43134
0.50336 0.3335 0.67059 -0.43091
Thanks

As #minorlogic also wrote in their comment, these jumps occur near the circular limits of (0,2pi] or (-pi,pi] -- or, in terms of unit quaternions (being constructed as [cos(phi), sin(phi) * rotAxis]), more appropriately in the range (-1,1] for each component.
Most IMUs however don't represent their orientation readings in a normalised fashion, though, but the normalisation factor(s) should be stated in the data sheet (as #daniel-wisehart mentioned in their comment). When applying these factors, you should obtain a quaternion representation with values between -1 and 1. These overflows will still be present, though, as these are basically a normalisation requirement (i.e. to keep the unit part of unit quaternions).

Related

How to include 3 interactions with a SINGLE predictor in lmer

I know that I could use lm(a ~ (b + c + d)^2) in order to get all possible two-way interactions in a model, but I need only the interactions with a single predictor. Let's say I want the possible interaction of B + C + D with predictor E.
I've tried:
lmer(MyVar ~ (1|ID) + (B + C + D)^E, data = data, REML = F)
Error in terms.formula(formula, data = data) :
invalid power in formula
I know that I could hard code each interaction with either * or :, but I suppose there's a simple way to do that all at once, isn't there? Thanks in advance.
Peter already provided an answer in the comments, but just so there is a worked example here, I have used the carrots dataset from the lmerTest package to fit this kind of model.
#### Load Library ####
library(lmerTest)
#### Fit 3 Interactions with Predictor ####
fit <- lmer(Preference
~ (Work + Homesize + Age) * sens2
+ (1 + sens2 | Consumer),
data=carrots)
summary(fit)
This specific model has more than 12 parameters, so it gives a warning at the that it can't show the entire correlation matrix at the end:
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula:
Preference ~ (Work + Homesize + Age) * sens2 + (1 + sens2 | Consumer)
Data: carrots
REML criterion at convergence: 3793
Scaled residuals:
Min 1Q Median 3Q Max
-3.5393 -0.5531 0.0221 0.6129 3.0304
Random effects:
Groups Name Variance Std.Dev. Corr
Consumer (Intercept) 0.194588 0.44112
sens2 0.002667 0.05164 0.30
Residual 1.070431 1.03462
Number of obs: 1233, groups: Consumer, 103
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 4.599943 0.269675 92.130730 17.057 <2e-16 ***
Work2 0.252784 0.215224 92.355377 1.175 0.2432
Work3 0.049107 0.202453 92.620270 0.243 0.8089
Work4 0.350115 0.241920 92.357943 1.447 0.1512
Work5 -0.172296 0.251901 92.336511 -0.684 0.4957
Work6 0.142940 0.306935 92.245988 0.466 0.6425
Work7 0.284870 0.222300 92.466369 1.281 0.2032
Homesize3 -0.210541 0.117745 92.054098 -1.788 0.0770 .
Age2 0.147557 0.258083 91.931134 0.572 0.5689
Age3 0.175345 0.244237 91.940161 0.718 0.4746
Age4 0.143185 0.286984 91.891878 0.499 0.6190
sens2 -0.005156 0.048716 92.036870 -0.106 0.9159
Work2:sens2 -0.026848 0.038861 92.096571 -0.691 0.4914
Work3:sens2 0.025743 0.036536 92.167106 0.705 0.4828
Work4:sens2 0.020395 0.043681 92.097263 0.467 0.6417
Work5:sens2 0.041402 0.045486 92.091579 0.910 0.3651
Work6:sens2 0.041545 0.055435 92.076468 0.749 0.4555
Work7:sens2 -0.026257 0.040130 92.126134 -0.654 0.5145
Homesize3:sens2 0.034216 0.021273 92.017206 1.608 0.1112
Age2:sens2 0.050271 0.046641 91.984618 1.078 0.2839
Age3:sens2 0.049982 0.044137 91.986480 1.132 0.2604
Age4:sens2 0.098257 0.051868 91.973468 1.894 0.0613 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation matrix not shown by default, as p = 22 > 12.
Use print(x, correlation=TRUE) or
vcov(x) if you need it
Since this may be common for models that have a lot of interaction terms, you can simply follow the advice given with the warning and just run vcov(fit) to see the rest:
22 x 22 Matrix of class "dpoMatrix"
(Intercept) Work2 Work3 Work4
(Intercept) 0.0727247177 -2.460271e-02 -2.159223e-02 -2.485573e-02
Work2 -0.0246027147 4.632157e-02 2.731653e-02 2.605219e-02
Work3 -0.0215922283 2.731653e-02 4.098720e-02 2.751607e-02
Work4 -0.0248557275 2.605219e-02 2.751607e-02 5.852536e-02
Work5 -0.0188462642 2.535069e-02 2.746376e-02 2.638325e-02
Work6 -0.0590599021 2.577976e-02 2.074795e-02 2.352827e-02
Work7 -0.0196165301 2.525230e-02 2.745152e-02 2.594625e-02
Homesize3 -0.0109607544 -3.400679e-04 3.870252e-03 2.706524e-03
Age2 -0.0407749626 -6.515489e-03 -1.335698e-02 -4.201862e-03
Age3 -0.0494575617 -7.385083e-04 -7.919796e-03 -3.694373e-03
Age4 -0.0511840024 -5.047503e-04 -6.213891e-03 -8.488546e-04
sens2 0.0017103436 -5.694673e-04 -4.960309e-04 -5.737888e-04
Work2:sens2 -0.0005694673 1.082713e-03 6.301142e-04 6.007327e-04
Work3:sens2 -0.0004960308 6.301141e-04 9.510769e-04 6.326784e-04
Work4:sens2 -0.0005737887 6.007327e-04 6.326785e-04 1.367865e-03
Work5:sens2 -0.0004311883 5.838187e-04 6.310805e-04 6.061557e-04
Work6:sens2 -0.0013903112 5.995643e-04 4.776545e-04 5.446369e-04
Work7:sens2 -0.0004495020 5.815462e-04 6.308496e-04 5.958678e-04
Homesize3:sens2 -0.0002555305 -1.271474e-05 8.614862e-05 5.884019e-05
Age2:sens2 -0.0009699655 -1.494199e-04 -3.104255e-04 -9.394093e-05
Age3:sens2 -0.0011767009 -1.158708e-05 -1.805710e-04 -8.082443e-05
Age4:sens2 -0.0012155754 -8.270833e-06 -1.427594e-04 -1.592515e-05
Work5 Work6 Work7 Homesize3
(Intercept) -1.884626e-02 -5.905990e-02 -1.961653e-02 -1.096075e-02
Work2 2.535069e-02 2.577976e-02 2.525230e-02 -3.400679e-04
Work3 2.746376e-02 2.074795e-02 2.745152e-02 3.870252e-03
Work4 2.638325e-02 2.352827e-02 2.594625e-02 2.706524e-03
Work5 6.345422e-02 1.792640e-02 3.446007e-02 2.839939e-03
Work6 1.792640e-02 9.420917e-02 1.785281e-02 1.291156e-03
Work7 3.446007e-02 1.785281e-02 4.941720e-02 4.034687e-03
Homesize3 2.839939e-03 1.291156e-03 4.034687e-03 1.386395e-02
Age2 -7.707013e-03 3.230279e-02 -7.764027e-03 -1.515922e-03
Age3 -1.021223e-02 4.033104e-02 -9.334598e-03 2.906882e-03
Age4 -1.878498e-02 4.116822e-02 -2.475574e-02 4.240265e-03
sens2 -4.311884e-04 -1.390312e-03 -4.495020e-04 -2.555306e-04
Work2:sens2 5.838188e-04 5.995648e-04 5.815462e-04 -1.271468e-05
Work3:sens2 6.310805e-04 4.776551e-04 6.308496e-04 8.614867e-05
Work4:sens2 6.061557e-04 5.446375e-04 5.958678e-04 5.884025e-05
Work5:sens2 1.483935e-03 4.114916e-04 7.971930e-04 6.188087e-05
Work6:sens2 4.114910e-04 2.207829e-03 4.096409e-04 2.535023e-05
Work7:sens2 7.971929e-04 4.096415e-04 1.151554e-03 9.018370e-05
Homesize3:sens2 6.188081e-05 2.535036e-05 9.018363e-05 3.267278e-04
Age2:sens2 -1.768088e-04 7.730782e-04 -1.781380e-04 -3.387819e-05
Age3:sens2 -2.350601e-04 9.623697e-04 -2.142697e-04 7.102571e-05
Age4:sens2 -4.406804e-04 9.803703e-04 -5.821051e-04 1.018839e-04
Age2 Age3 Age4 sens2
(Intercept) -4.077496e-02 -4.945756e-02 -5.118400e-02 0.0017103436
Work2 -6.515489e-03 -7.385083e-04 -5.047503e-04 -0.0005694673
Work3 -1.335698e-02 -7.919796e-03 -6.213891e-03 -0.0004960309
Work4 -4.201862e-03 -3.694373e-03 -8.488546e-04 -0.0005737888
Work5 -7.707013e-03 -1.021223e-02 -1.878498e-02 -0.0004311884
Work6 3.230279e-02 4.033104e-02 4.116822e-02 -0.0013903117
Work7 -7.764027e-03 -9.334598e-03 -2.475574e-02 -0.0004495020
Homesize3 -1.515922e-03 2.906882e-03 4.240265e-03 -0.0002555306
Age2 6.660707e-02 4.917829e-02 4.874852e-02 -0.0009699654
Age3 4.917829e-02 5.965166e-02 5.751230e-02 -0.0011767008
Age4 4.874852e-02 5.751230e-02 8.235963e-02 -0.0012155754
sens2 -9.699654e-04 -1.176701e-03 -1.215575e-03 0.0023732002
Work2:sens2 -1.494201e-04 -1.158717e-05 -8.270915e-06 -0.0008009534
Work3:sens2 -3.104256e-04 -1.805711e-04 -1.427594e-04 -0.0007021649
Work4:sens2 -9.394109e-05 -8.082452e-05 -1.592525e-05 -0.0008088714
Work5:sens2 -1.768090e-04 -2.350602e-04 -4.406805e-04 -0.0006125030
Work6:sens2 7.730783e-04 9.623699e-04 9.803704e-04 -0.0019275339
Work7:sens2 -1.781381e-04 -2.142698e-04 -5.821052e-04 -0.0006376798
Homesize3:sens2 -3.387822e-05 7.102570e-05 1.018839e-04 -0.0003572095
Age2:sens2 1.574981e-03 1.162241e-03 1.152849e-03 -0.0013328873
Age3:sens2 1.162241e-03 1.410198e-03 1.360446e-03 -0.0016167476
Age4:sens2 1.152849e-03 1.360446e-03 1.949606e-03 -0.0016727270
Work2:sens2 Work3:sens2 Work4:sens2 Work5:sens2
(Intercept) -5.694673e-04 -4.960308e-04 -5.737887e-04 -4.311883e-04
Work2 1.082713e-03 6.301141e-04 6.007327e-04 5.838187e-04
Work3 6.301142e-04 9.510769e-04 6.326785e-04 6.310805e-04
Work4 6.007327e-04 6.326784e-04 1.367865e-03 6.061557e-04
Work5 5.838188e-04 6.310805e-04 6.061557e-04 1.483935e-03
Work6 5.995648e-04 4.776551e-04 5.446375e-04 4.114916e-04
Work7 5.815462e-04 6.308496e-04 5.958678e-04 7.971930e-04
Homesize3 -1.271468e-05 8.614867e-05 5.884025e-05 6.188087e-05
Age2 -1.494201e-04 -3.104256e-04 -9.394109e-05 -1.768090e-04
Age3 -1.158717e-05 -1.805711e-04 -8.082452e-05 -2.350602e-04
Age4 -8.270915e-06 -1.427594e-04 -1.592525e-05 -4.406805e-04
sens2 -8.009534e-04 -7.021649e-04 -8.088714e-04 -6.125030e-04
Work2:sens2 1.510208e-03 8.888542e-04 8.476685e-04 8.246902e-04
Work3:sens2 8.888542e-04 1.334852e-03 8.949241e-04 8.931412e-04
Work4:sens2 8.476685e-04 8.949241e-04 1.908065e-03 8.579816e-04
Work5:sens2 8.246902e-04 8.931412e-04 8.579816e-04 2.068938e-03
Work6:sens2 8.398725e-04 6.749491e-04 7.659950e-04 5.829051e-04
Work7:sens2 8.214882e-04 8.927538e-04 8.437191e-04 1.121775e-03
Homesize3:sens2 -1.207554e-05 1.252882e-04 8.732358e-05 9.165766e-05
Age2:sens2 -2.118283e-04 -4.351115e-04 -1.361084e-04 -2.505820e-04
Age3:sens2 -2.290075e-05 -2.572678e-04 -1.193013e-04 -3.321938e-04
Age4:sens2 -1.572527e-05 -2.020783e-04 -2.686406e-05 -6.127763e-04
Work6:sens2 Work7:sens2 Homesize3:sens2
(Intercept) -1.390311e-03 -0.0004495020 -2.555305e-04
Work2 5.995643e-04 0.0005815462 -1.271474e-05
Work3 4.776545e-04 0.0006308496 8.614862e-05
Work4 5.446369e-04 0.0005958678 5.884019e-05
Work5 4.114910e-04 0.0007971929 6.188081e-05
Work6 2.207829e-03 0.0004096415 2.535036e-05
Work7 4.096409e-04 0.0011515535 9.018363e-05
Homesize3 2.535023e-05 0.0000901837 3.267278e-04
Age2 7.730783e-04 -0.0001781381 -3.387822e-05
Age3 9.623699e-04 -0.0002142698 7.102570e-05
Age4 9.803704e-04 -0.0005821052 1.018839e-04
sens2 -1.927534e-03 -0.0006376798 -3.572095e-04
Work2:sens2 8.398725e-04 0.0008214882 -1.207554e-05
Work3:sens2 6.749491e-04 0.0008927538 1.252882e-04
Work4:sens2 7.659950e-04 0.0008437191 8.732358e-05
Work5:sens2 5.829051e-04 0.0011217754 9.165766e-05
Work6:sens2 3.072991e-03 0.0005804819 4.112908e-05
Work7:sens2 5.804819e-04 0.0016104051 1.306882e-04
Homesize3:sens2 4.112908e-05 0.0001306882 4.525614e-04
Age2:sens2 1.056816e-03 -0.0002524409 -4.911036e-05
Age3:sens2 1.318931e-03 -0.0003035236 9.540544e-05
Age4:sens2 1.345904e-03 -0.0008078267 1.388138e-04
Age2:sens2 Age3:sens2 Age4:sens2
(Intercept) -9.699655e-04 -1.176701e-03 -1.215575e-03
Work2 -1.494199e-04 -1.158708e-05 -8.270833e-06
Work3 -3.104255e-04 -1.805710e-04 -1.427594e-04
Work4 -9.394093e-05 -8.082443e-05 -1.592515e-05
Work5 -1.768088e-04 -2.350601e-04 -4.406804e-04
Work6 7.730782e-04 9.623697e-04 9.803703e-04
Work7 -1.781380e-04 -2.142697e-04 -5.821051e-04
Homesize3 -3.387819e-05 7.102571e-05 1.018839e-04
Age2 1.574981e-03 1.162241e-03 1.152849e-03
Age3 1.162241e-03 1.410198e-03 1.360446e-03
Age4 1.152849e-03 1.360446e-03 1.949606e-03
sens2 -1.332887e-03 -1.616748e-03 -1.672727e-03
Work2:sens2 -2.118283e-04 -2.290075e-05 -1.572527e-05
Work3:sens2 -4.351115e-04 -2.572678e-04 -2.020783e-04
Work4:sens2 -1.361084e-04 -1.193013e-04 -2.686406e-05
Work5:sens2 -2.505820e-04 -3.321938e-04 -6.127763e-04
Work6:sens2 1.056816e-03 1.318931e-03 1.345904e-03
Work7:sens2 -2.524409e-04 -3.035236e-04 -8.078267e-04
Homesize3:sens2 -4.911036e-05 9.540544e-05 1.388138e-04
Age2:sens2 2.175354e-03 1.606007e-03 1.592130e-03
Age3:sens2 1.606007e-03 1.948116e-03 1.878419e-03
Age4:sens2 1.592130e-03 1.878419e-03 2.690248e-03

I have 2 graphs on R. They have different x axis, but similar trend profile. how do I overlay them on r?

I have 2 datasets (First and Second) shown below on their respective raw datasets.
They have different x-axis, but similar trend profile.
How do I align and overlay them to occur on a single plot on R using ggplot2?
My codes for their plots on R are:
For First:
First <- ggplot(data = First,
aes(x, y)) +
geom_line(pch = 1)
For Second:
Second <- ggplot(data = Second,
aes(x, y)) +
geom_line(pch = 1)
Raw dataset for First:
x y
129.46 532.87
129.44 533.97
129.43 534.48
129.42 524.14
129.40 525.10
129.39 517.73
129.37 517.06
129.36 517.98
129.35 511.68
129.33 506.21
129.32 503.39
129.31 492.87
129.29 484.60
129.28 481.26
129.26 473.19
129.25 469.08
129.24 464.39
129.22 456.28
129.21 452.46
129.19 447.01
129.18 439.83
129.17 434.11
129.15 426.85
129.14 421.21
129.12 414.52
129.11 409.71
129.10 404.59
129.08 399.91
129.07 393.89
129.05 388.65
129.04 383.33
129.03 379.13
129.01 375.56
129.00 370.54
128.98 366.30
128.97 362.54
128.96 356.00
128.94 351.95
128.93 347.81
128.91 343.64
128.90 339.57
128.89 335.33
128.87 331.19
128.86 328.30
128.84 325.86
128.83 323.46
128.82 321.77
128.80 319.47
128.79 316.96
128.77 314.35
128.76 311.30
128.75 308.95
128.73 307.41
128.72 304.59
128.70 302.33
128.69 299.55
128.68 297.95
128.66 296.19
128.65 294.39
128.63 292.42
128.62 289.79
128.61 287.52
128.59 285.54
128.58 283.74
128.57 281.68
128.55 279.89
128.54 278.65
128.52 277.48
128.51 275.45
128.50 273.93
128.48 272.46
128.47 271.14
128.45 269.65
128.44 267.75
128.43 266.05
128.41 264.15
128.40 262.82
128.38 261.77
128.37 261.36
128.36 260.28
128.34 259.67
128.33 258.81
128.31 258.05
128.30 258.05
128.29 257.27
128.27 256.64
128.26 256.02
128.24 254.40
128.23 253.57
128.22 252.97
128.20 252.69
128.19 252.08
128.17 251.61
128.16 250.88
128.15 250.67
128.13 250.52
128.12 249.97
128.10 249.84
128.09 248.82
128.08 249.06
128.06 248.00
128.05 247.06
128.03 246.84
128.02 247.20
128.01 248.07
127.99 247.46
127.98 246.58
127.96 246.86
127.95 247.03
127.94 246.67
127.92 247.20
127.91 247.80
127.90 247.61
127.88 247.87
127.87 247.77
127.85 247.42
127.84 248.48
127.83 248.90
127.81 249.92
127.80 251.29
127.78 252.16
127.77 253.10
127.76 254.39
127.74 255.47
127.73 256.43
127.71 257.68
127.70 258.32
127.69 259.63
127.67 261.89
127.66 263.23
127.64 265.47
127.63 267.10
127.62 269.05
127.60 271.09
127.59 272.48
127.57 274.91
127.56 276.54
127.55 278.50
127.53 279.27
127.52 280.13
127.50 280.96
127.49 281.58
127.48 281.73
127.46 282.27
127.45 282.77
127.43 282.81
127.42 282.59
127.41 282.14
127.39 281.05
127.38 280.53
127.36 279.07
127.35 277.24
127.34 276.30
127.32 274.52
127.31 272.61
127.29 271.43
127.28 270.06
127.27 268.06
127.25 267.17
127.24 265.80
127.23 264.93
127.21 264.38
127.20 263.39
127.18 263.05
127.17 262.48
127.16 261.55
127.14 261.36
127.13 260.32
127.11 259.54
127.10 260.12
127.09 260.55
127.07 260.92
127.06 261.55
127.04 262.40
127.03 262.71
127.02 263.56
127.00 264.18
126.99 264.76
126.97 264.76
126.96 264.48
126.95 265.54
126.93 267.23
126.92 268.28
126.90 269.27
126.89 270.39
126.88 271.40
126.86 272.81
126.85 273.91
126.83 275.63
126.82 277.38
126.81 277.79
126.79 279.41
126.78 279.75
126.76 280.53
126.75 282.72
126.74 284.13
126.72 286.31
126.71 288.78
126.69 290.37
126.68 292.47
126.67 294.45
126.65 296.41
126.64 299.01
126.62 300.27
126.61 300.60
126.60 302.39
126.58 304.41
126.57 306.27
126.56 309.08
126.54 311.47
126.53 314.92
126.51 317.62
126.50 320.79
126.49 324.88
126.47 327.88
126.46 331.98
126.44 334.43
126.43 336.38
126.42 339.31
126.40 342.30
126.39 345.26
126.37 349.00
126.36 353.23
126.35 355.80
126.33 359.43
126.32 362.46
126.30 365.44
126.29 368.90
126.28 371.33
126.26 373.43
126.25 375.84
126.23 376.66
126.22 377.24
126.21 378.86
126.19 380.56
126.18 382.81
126.16 384.93
126.15 386.63
126.14 389.33
126.12 392.04
126.11 393.12
126.09 395.23
126.08 397.14
126.07 397.97
126.05 398.70
126.04 400.18
126.02 402.96
126.01 406.16
126.00 410.46
125.98 414.02
125.97 419.10
125.95 423.51
125.94 429.04
125.93 433.63
125.91 439.10
125.90 445.74
125.88 448.74
125.87 454.18
125.86 458.68
125.84 464.89
125.83 471.47
125.82 479.85
125.80 487.35
125.79 495.42
125.77 505.03
125.76 514.95
125.75 525.05
125.73 536.33
125.72 545.53
125.70 555.22
125.69 566.94
125.68 578.38
125.66 592.60
125.65 610.46
125.63 627.96
125.62 644.92
125.61 667.07
125.59 690.26
125.58 716.45
125.56 743.96
125.55 772.56
125.54 802.98
125.52 834.70
125.51 861.03
125.49 893.29
125.48 928.74
125.47 959.44
125.45 986.00
125.44 1007.16
125.42 1025.04
125.41 1037.34
125.40 1045.97
125.38 1047.54
125.37 1046.52
125.35 1040.06
125.34 1033.93
125.33 1028.62
125.31 1019.46
125.30 1009.75
125.28 998.56
125.27 985.23
125.26 969.51
125.24 954.00
125.23 937.87
125.21 921.84
125.20 904.31
125.19 886.50
125.17 869.52
125.16 855.01
125.15 841.79
125.13 826.35
125.12 812.49
125.10 798.08
125.09 783.09
125.08 768.02
125.06 751.49
125.05 735.61
125.03 720.00
125.02 705.38
125.01 690.72
124.99 676.87
124.98 663.52
124.96 652.62
124.95 642.21
124.94 631.57
124.92 620.73
124.91 609.34
124.89 599.22
124.88 589.48
124.87 578.93
124.85 569.27
124.84 557.89
124.82 548.03
124.81 539.04
124.80 529.46
124.78 520.41
124.77 512.79
124.75 504.41
124.74 494.50
124.73 484.16
124.71 474.33
124.70 463.87
124.68 453.91
124.67 442.96
124.66 432.59
124.64 421.67
124.63 412.34
124.61 402.25
124.60 391.99
124.59 384.48
124.57 375.79
124.56 366.30
124.54 357.78
124.53 349.52
124.52 340.83
124.50 333.56
124.49 324.78
124.48 316.03
124.46 308.79
124.45 301.12
124.43 294.10
124.42 287.40
124.41 280.85
124.39 275.99
124.38 269.42
124.36 264.00
124.35 258.31
124.34 252.82
124.32 248.27
124.31 243.83
124.29 239.23
124.28 234.31
124.27 230.57
124.25 226.70
124.24 222.75
124.22 219.43
124.21 215.93
124.20 212.76
124.18 209.68
124.17 206.41
124.15 203.55
124.14 200.64
124.13 198.50
124.11 196.15
124.10 193.52
124.08 191.50
124.07 189.29
124.06 187.49
124.04 185.83
124.03 184.40
124.01 182.50
124.00 181.13
123.99 179.58
123.97 178.32
123.96 177.52
123.94 176.60
123.93 175.97
123.92 175.14
123.90 174.42
123.89 173.82
123.87 173.33
123.86 172.90
123.85 172.59
123.83 172.14
123.82 171.81
123.80 171.40
123.79 171.32
123.78 171.27
123.76 171.26
123.75 171.29
123.74 171.30
123.72 171.15
123.71 171.20
123.69 171.05
123.68 170.71
123.67 170.44
123.65 170.09
123.64 169.57
123.62 168.99
123.61 168.32
123.60 167.77
123.58 167.32
123.57 166.69
123.55 166.03
123.54 165.45
123.53 164.87
123.51 164.10
123.50 163.33
123.48 162.63
123.47 162.00
123.46 161.37
123.44 160.56
123.43 159.85
123.41 159.23
123.40 158.66
123.39 158.23
123.37 157.77
123.36 157.43
123.34 157.03
123.33 156.67
123.32 156.09
123.30 155.41
123.29 155.02
123.27 154.63
123.26 154.00
123.25 153.36
123.23 152.90
123.22 152.52
123.20 152.22
123.19 151.95
123.18 151.78
123.16 151.64
123.15 151.54
123.13 151.23
123.12 150.99
123.11 150.81
123.09 150.59
123.08 150.38
123.07 150.11
123.05 149.89
123.04 149.75
123.02 149.66
123.01 149.63
123.00 149.83
122.98 150.07
122.97 150.18
122.95 150.38
122.94 150.48
122.93 150.76
122.91 151.21
122.90 151.06
122.88 151.18
122.87 151.47
122.86 151.93
122.84 152.12
122.83 152.41
122.81 152.93
122.80 153.56
122.79 154.44
122.77 155.16
122.76 155.76
122.74 156.56
122.73 157.35
122.72 158.24
122.70 159.00
122.69 159.72
122.67 160.70
122.66 161.41
122.65 162.03
122.63 162.70
122.62 163.31
122.60 163.98
122.59 164.61
122.58 165.13
122.56 165.54
122.55 165.72
122.53 165.78
122.52 165.61
122.51 165.27
122.49 164.97
122.48 164.62
122.46 164.08
122.45 163.49
122.44 162.59
122.42 161.87
122.41 161.26
122.40 160.59
122.38 160.01
122.37 159.52
122.35 158.90
122.34 158.05
122.33 157.02
122.31 156.18
122.30 155.43
122.28 154.64
122.27 153.81
122.26 153.00
122.24 152.30
122.23 151.48
122.21 150.83
122.20 150.15
122.19 149.72
122.17 149.32
122.16 148.91
122.14 148.41
122.13 148.05
122.12 147.78
122.10 147.31
122.09 146.96
122.07 146.90
122.06 146.74
122.05 146.55
122.03 146.53
122.02 147.33
122.00 146.93
121.99 146.75
121.98 146.76
121.96 146.89
121.95 147.08
121.93 147.47
121.92 147.95
121.91 148.47
121.89 148.91
121.88 149.44
121.86 150.03
121.85 150.46
121.84 150.94
121.82 151.46
121.81 152.04
121.79 152.43
121.78 152.67
121.77 152.92
121.75 153.19
121.74 153.50
121.72 153.58
121.71 153.69
121.70 153.81
121.68 153.71
121.67 153.58
121.66 153.20
121.64 152.85
121.63 152.70
121.61 152.24
121.60 151.67
121.59 150.90
121.57 150.41
121.56 149.84
121.54 149.28
121.53 148.58
121.52 148.05
121.50 147.70
121.49 147.15
121.47 146.79
121.46 146.48
121.45 146.24
121.43 145.94
121.42 145.52
121.40 145.30
121.39 145.38
121.38 145.36
121.36 145.28
121.35 145.65
121.33 145.55
121.32 145.75
121.31 146.25
121.29 146.42
121.28 146.81
121.26 147.12
121.25 147.17
121.24 147.47
121.22 147.71
121.21 147.78
121.19 147.95
121.18 148.34
121.17 148.32
121.15 148.54
121.14 148.44
121.12 148.52
121.11 148.70
121.10 148.77
121.08 148.92
121.07 148.95
121.05 148.73
121.04 148.28
121.03 148.15
121.01 147.66
121.00 147.44
120.99 147.17
120.97 146.65
120.96 146.66
120.94 146.30
120.93 146.32
120.92 146.36
120.90 146.05
120.89 146.16
120.87 145.92
120.86 145.57
120.85 145.71
120.83 145.05
120.82 145.49
120.80 145.59
120.79 145.24
120.78 145.48
120.76 146.02
120.75 145.67
120.73 146.44
120.72 147.36
120.71 147.80
120.69 148.87
120.68 147.89
120.66 148.12
120.65 148.79
120.64 147.28
120.62 148.47
120.61 149.10
120.59 149.42
120.58 149.45
120.57 149.90
120.55 150.28
120.54 150.52
120.52 150.43
120.51 150.94
120.50 150.73
120.48 151.13
120.47 151.24
120.45 151.32
120.44 150.96
120.43 150.80
120.41 150.61
120.40 150.41
120.38 150.48
120.37 150.96
120.36 151.60
120.34 152.14
120.33 152.05
120.32 152.51
120.30 152.53
120.29 152.56
120.27 152.63
120.26 152.53
120.25 152.28
120.23 151.96
120.22 150.96
120.20 149.81
120.19 149.15
120.18 148.75
120.16 148.42
120.15 147.90
120.13 147.60
120.12 147.37
120.11 146.73
120.09 146.94
120.08 146.99
120.06 146.53
120.05 146.26
120.04 147.40
120.02 149.56
120.01 148.57
119.99 150.23
119.98 148.50
119.97 149.44
119.95 153.75
119.94 154.59
119.92 158.31
119.91 163.60
119.90 170.53
119.88 176.49
119.87 183.77
119.85 195.72
119.84 199.95
119.83 203.86
119.81 196.98
119.80 186.12
119.78 181.83
The second is:
x y
142.06 483.07
142.05 481.22
142.03 480.65
142.02 477.31
142.01 469.69
141.99 461.74
141.98 455.80
141.96 450.03
141.95 440.94
141.94 436.92
141.92 439.83
141.91 448.89
141.89 451.64
141.88 445.06
141.87 436.29
141.85 436.91
141.84 439.85
141.82 438.04
141.81 437.54
141.80 440.88
141.78 440.12
141.77 441.93
141.75 441.75
141.74 443.65
141.73 437.05
141.71 435.76
141.70 438.81
141.68 442.95
141.67 445.62
141.66 445.92
141.64 445.68
141.63 441.25
141.62 440.84
141.60 435.75
141.59 429.87
141.57 429.70
141.56 435.20
141.55 434.71
141.53 433.26
141.52 433.86
141.50 435.97
141.49 436.62
141.48 438.29
141.46 436.82
141.45 436.19
141.43 430.53
141.42 425.53
141.41 423.40
141.39 422.70
141.38 427.22
141.36 429.55
141.35 430.31
141.34 433.64
141.32 437.53
141.31 436.35
141.29 436.65
141.28 439.47
141.27 437.66
141.25 436.88
141.24 428.98
141.22 426.74
141.21 431.80
141.20 434.16
141.18 436.85
141.17 439.57
141.15 441.25
141.14 446.21
141.13 445.51
141.11 446.65
141.10 448.60
141.08 445.50
141.07 442.42
141.06 439.73
141.04 437.68
141.03 439.24
141.01 445.00
141.00 446.63
140.99 451.07
140.97 452.34
140.96 453.97
140.94 458.24
140.93 459.39
140.92 462.71
140.90 464.21
140.89 462.70
140.87 462.00
140.86 460.58
140.85 460.49
140.83 464.55
140.82 471.15
140.80 470.22
140.79 472.05
140.78 472.89
140.76 475.38
140.75 478.31
140.73 479.60
140.72 483.60
140.71 486.64
140.69 490.09
140.68 490.27
140.67 490.00
140.65 493.38
140.64 499.44
140.62 499.82
140.61 501.45
140.60 502.86
140.58 503.88
140.57 505.28
140.55 506.91
140.54 511.23
140.53 515.51
140.51 517.53
140.50 517.70
140.48 517.27
140.47 517.27
140.46 514.41
140.44 513.87
140.43 513.18
140.41 510.40
140.40 502.88
140.39 499.08
140.37 494.34
140.36 493.15
140.34 497.87
140.33 499.36
140.32 498.40
140.30 495.46
140.29 490.72
140.27 485.64
140.26 479.75
140.25 474.79
140.23 470.13
140.22 461.47
140.20 459.50
140.19 457.55
140.18 455.43
140.16 461.16
140.15 469.09
140.13 471.04
140.12 469.66
140.11 462.89
140.09 454.46
140.08 448.36
140.06 440.22
140.05 432.27
140.04 424.39
140.02 418.62
140.01 416.53
139.99 414.79
139.98 418.52
139.97 429.46
139.95 439.80
139.94 446.26
139.92 443.80
139.91 438.85
139.90 432.84
139.88 431.29
139.87 427.68
139.85 422.87
139.84 419.23
139.83 414.42
139.81 411.25
139.80 413.78
139.79 419.72
139.77 424.95
139.76 429.25
139.74 427.59
139.73 422.81
139.72 417.27
139.70 416.84
139.69 417.09
139.67 414.80
139.66 412.47
139.65 413.25
139.63 412.05
139.62 416.88
139.60 421.99
139.59 425.06
139.58 434.19
139.56 436.34
139.55 435.10
139.53 430.10
139.52 431.28
139.51 433.26
139.49 434.26
139.48 431.66
139.46 433.82
139.45 436.17
139.44 438.31
139.42 445.14
139.41 452.12
139.39 460.34
139.38 468.53
139.37 469.48
139.35 467.94
139.34 471.17
139.32 475.65
139.31 478.09
139.30 477.27
139.28 478.26
139.27 477.40
139.25 480.09
139.24 485.09
139.23 491.05
139.21 496.55
139.20 500.31
139.18 502.52
139.17 498.99
139.16 497.95
139.14 498.37
139.13 500.68
139.11 503.28
139.10 505.85
139.09 506.35
139.07 507.11
139.06 513.07
139.04 520.05
139.03 527.38
139.02 532.70
139.00 536.39
138.99 541.80
138.97 544.73
138.96 547.06
138.95 551.20
138.93 554.44
138.92 558.82
138.90 564.68
138.89 569.71
138.88 580.95
138.86 593.55
138.85 606.50
138.84 621.86
138.82 632.23
138.81 639.43
138.79 649.10
138.78 661.02
138.77 672.71
138.75 683.65
138.74 697.95
138.72 711.85
138.71 721.70
138.70 742.52
138.68 764.57
138.67 786.43
138.65 812.39
138.64 838.32
138.63 862.37
138.61 882.57
138.60 908.42
138.58 937.86
138.57 962.48
138.56 986.73
138.54 1015.64
138.53 1040.43
138.51 1068.36
138.50 1104.88
138.49 1143.82
138.47 1190.99
138.46 1232.34
138.44 1273.42
138.43 1296.43
138.42 1323.50
138.40 1347.81
138.39 1363.65
138.37 1369.67
138.36 1382.39
138.35 1388.82
138.33 1389.04
138.32 1391.43
138.30 1393.68
138.29 1398.80
138.28 1394.21
138.26 1384.65
138.25 1364.55
138.23 1337.52
138.22 1326.20
138.21 1306.90
138.19 1283.38
138.18 1270.16
138.16 1249.03
138.15 1230.29
138.14 1223.17
138.12 1213.08
138.11 1211.40
138.09 1212.51
138.08 1200.52
138.07 1185.42
138.05 1161.96
138.04 1143.77
138.02 1123.02
138.01 1093.99
138.00 1077.22
137.98 1059.70
137.97 1035.84
137.96 1027.20
137.94 1025.29
137.93 1015.19
137.91 1012.58
137.90 1006.32
137.89 984.20
137.87 964.25
137.86 941.66
137.84 922.75
137.83 906.69
137.82 882.85
137.80 871.76
137.79 857.74
137.77 848.72
137.76 846.38
137.75 839.06
137.73 833.21
137.72 822.04
137.70 804.83
137.69 783.16
137.68 774.40
137.66 758.48
137.65 744.32
137.63 732.52
137.62 722.43
137.61 712.14
137.59 704.13
137.58 699.86
137.56 697.26
137.55 692.86
137.54 684.29
137.52 669.33
137.51 650.79
137.49 639.53
137.48 630.92
137.47 619.08
137.45 607.80
137.44 599.49
137.42 587.80
137.41 579.81
137.40 571.73
137.38 564.87
137.37 559.58
137.35 549.88
137.34 538.16
137.33 525.07
137.31 514.06
137.30 505.49
137.28 497.80
137.27 487.99
137.26 479.18
137.24 470.91
137.23 460.88
137.21 455.19
137.20 448.80
137.19 440.92
137.17 434.03
137.16 424.79
137.14 416.53
137.13 408.00
137.12 401.20
137.10 394.36
137.09 387.62
137.07 380.90
137.06 374.20
137.05 367.24
137.03 360.99
137.02 354.70
137.01 348.64
136.99 342.50
136.98 335.56
136.96 329.23
136.95 322.95
136.94 317.64
136.92 312.24
136.91 308.07
136.89 303.21
136.88 298.65
136.87 293.95
136.85 288.35
136.84 283.98
136.82 280.04
136.81 275.83
136.80 272.23
136.78 268.40
136.77 264.82
136.75 262.04
136.74 259.04
136.73 256.31
136.71 253.72
136.70 250.91
136.68 248.53
136.67 246.17
136.66 243.85
136.64 241.94
136.63 239.81
136.61 238.02
136.60 235.93
136.59 233.98
136.57 232.39
136.56 230.67
136.54 229.24
136.53 227.66
136.52 226.07
136.50 224.55
136.49 222.98
136.47 221.41
136.46 219.70
136.45 218.23
136.43 216.48
136.42 214.75
136.40 213.16
136.39 211.33
136.38 209.93
136.36 208.55
136.35 206.95
136.33 205.56
136.32 204.10
136.31 202.87
136.29 201.66
136.28 200.54
136.26 199.10
136.25 197.71
136.24 196.47
136.22 195.42
136.21 194.51
136.19 193.55
136.18 192.66
136.17 191.81
136.15 191.09
136.14 190.37
136.13 189.78
136.11 189.06
136.10 188.53
136.08 187.81
136.07 187.02
136.06 186.32
136.04 185.86
136.03 185.72
136.01 185.46
136.00 185.06
135.99 184.91
135.97 184.74
135.96 184.66
135.94 184.70
135.93 184.75
135.92 184.67
135.90 184.74
135.89 185.58
135.87 184.94
135.86 184.83
135.85 185.37
135.83 185.96
135.82 186.52
135.80 187.16
135.79 187.97
135.78 188.76
135.76 189.75
135.75 190.56
135.73 191.43
135.72 192.48
135.71 193.43
135.69 194.49
135.68 195.61
135.66 196.96
135.65 198.34
135.64 199.56
135.62 200.90
135.61 202.40
135.59 203.76
135.58 205.23
135.57 206.56
135.55 207.97
135.54 209.31
135.52 210.44
135.51 211.36
135.50 212.20
135.48 212.95
135.47 213.47
135.45 213.92
135.44 214.11
135.43 214.10
135.41 213.94
135.40 213.64
135.38 213.19
135.37 212.59
135.36 211.82
135.34 210.75
135.33 209.66
135.31 208.46
135.30 207.14
135.29 205.82
135.27 204.44
135.26 203.15
135.24 201.80
135.23 200.48
135.22 199.35
135.20 198.28
135.19 197.23
135.18 196.15
135.16 195.07
135.15 194.03
135.13 192.96
135.12 192.21
135.11 191.53
135.09 190.87
135.08 190.32
135.06 190.02
135.05 189.82
135.04 189.84
135.02 189.89
135.01 189.82
134.99 190.02
134.98 189.88
134.97 190.09
134.95 190.45
134.94 190.82
134.92 191.60
134.91 192.45
134.90 193.26
134.88 194.27
134.87 195.37
134.85 196.61
134.84 197.86
134.83 199.11
134.81 200.35
134.80 201.58
134.78 202.68
134.77 203.60
134.76 204.22
134.74 205.07
134.73 206.51
134.71 209.37
134.70 206.97
134.69 207.18
134.67 207.52
134.66 207.90
134.64 208.21
134.63 208.21
134.62 208.27
134.60 207.19
134.59 206.58
134.57 205.72
134.56 204.81
134.55 204.11
134.53 203.64
134.52 202.92
134.50 202.02
134.49 201.22
134.48 200.36
134.46 199.68
134.45 198.92
134.43 198.29
134.42 197.56
134.41 196.73
134.39 196.08
134.38 195.75
134.36 195.52
134.35 195.63
134.34 195.81
134.32 196.02
134.31 196.20
134.30 196.80
134.28 196.90
134.27 197.19
134.25 197.74
134.24 198.08
134.23 198.31
134.21 198.68
134.20 199.22
134.18 199.70
134.17 200.18
134.16 200.93
134.14 201.64
134.13 202.24
134.11 202.68
134.10 203.27
134.09 203.68
134.07 204.09
134.06 204.19
134.04 204.23
134.03 204.12
134.02 204.37
134.00 203.50
133.99 202.88
133.97 202.47
133.96 202.08
133.95 201.85
133.93 201.56
133.92 201.16
133.90 201.05
133.89 200.73
133.88 200.97
133.86 202.35
133.85 201.84
133.83 198.75
133.82 197.11
133.81 196.25
133.79 195.58
133.78 195.22
133.76 195.54
133.75 195.44
133.74 195.13
133.72 195.43
133.71 195.90
133.69 196.28
133.68 196.45
133.67 197.47
133.65 197.88
133.64 199.96
133.62 205.28
133.61 198.80
133.60 196.61
133.58 194.43
133.57 193.35
133.55 191.96
133.54 190.94
133.53 189.94
133.51 188.91
133.50 187.44
133.48 187.05
133.47 200.13
133.46 194.78
133.44 183.44
133.43 183.11
133.41 182.48
133.40 181.97
133.39 184.17
133.37 181.21
133.36 184.86
133.35 183.46
133.33 181.41
133.32 181.87
133.30 182.53
133.29 182.31
133.28 181.29
133.26 181.50
133.25 181.17
133.23 184.41
133.22 183.61
133.21 186.67
133.19 182.59
133.18 181.21
133.16 180.85
133.15 184.65
133.14 184.11
133.12 182.34
133.11 189.83
133.09 190.95
133.08 199.73
133.07 214.60
133.05 223.41
133.04 220.76
133.02 248.98
133.01 296.96
133.00 308.09
132.98 263.16
enter code here
These data look like some kind of spectra, so I understand the desire to plot them on top of each other to compare shape. The following code aligns the peaks on each set, but you will have an arbitrary x-axis (so I removed the labels).
first$match <- first$x
second$match <- second$x - second$x[second$y == max(second$y)] + first$x[first$y == max(first$y)]
first$series = "first"
second$series = "second"
all_data = rbind(first, second)
ggplot(all_data) + geom_line(aes(x = match, y, color = series) +
scale_x_continuous(name = "X, arbitrary units") +
theme(axis.text.x = element_blank())
par(mfrow=c(1,2))
First
Second
should plot the two next to each other but not on top of each other.
Depending on how you want to visualize this you should combine the dataframes into a single dataframe with the source as a column. Then either have each on the same plot with a different colour etc., or use facet_wrap. Example:
library(tidyverse)
first <- tibble(x = 1:1000, y = x + runif(1000))
second <- tibble(x = 1001:2000, y = x + runif(1000))
combo <- first %>%
mutate(source = "first") %>%
bind_rows(
second %>%
mutate(source = "second")
)
combo %>%
ggplot(aes(x,y, colour = source))+
geom_line()
#or
combo %>%
ggplot(aes(x,y))+
geom_line()+
facet_wrap(~source)

How to plot an antenna pattern in a polar diagram in Octave?

I'm having some problems with polar plot in Octave. In particular I made a script that combine the horizontal and vertical antenna pattern in order to obtain the 3D antenna pattern of the antenna such that the result is a matrix of 360x360 elements. If I plot the matrix by means of surf function I obtain that image but I would like to get an antenna pattern diagram. How I can do that?
EDIT:
theta3D = linspace(0, 2*pi - (2*pi/360), 360);
phi3D = linspace(0, 2*pi - (2*pi/360), 360);
%% from dBm to dB
maxGainVdB = mGVNnA - 30;
maxGainHdB = mGHNnA - 30;
%% from dB to Watt
maxGainVWatt = 10.^(maxGainVdB/10);
maxGainHWatt = 10.^(maxGainHdB/10);
%% normalization
maxGainVWattNorm = maxGainVWatt./max(maxGainVWatt);
maxGainHWattNorm = maxGainHWatt./max(maxGainHWatt);
%% Gv and Gh
Gv = 10*log10(maxGainVWattNorm);
Gh = 10*log10(maxGainHWattNorm);
%% weighting factors
% where "i" is theta and j is phi
for i = 1 : length(phi3D)
for j = 1 : length(theta3D)
w1(i, j) = maxGainVWattNorm(i)*(1 - maxGainHWattNorm(j));
w2(i, j) = maxGainVWattNorm(j)*(1 - maxGainHWattNorm(i));
end
end
%% normalization-related parameter
k = 2; %% As indicated in Chapter 2
%% estimated G
for i = 1 : length(phi3D)
for j = 1 : length(theta3D)
estG(i, j) = ((Gh(i)*w1(i,j) + Gv(j)*w2(i,j))/((w1(i,j)^k + w2(i,j)^k))^(1/k));
end
end
figure
[X, Y] = meshgrid (theta3D, phi3D);
surf(X,Y,estG)
DATA
mGHNnA = [0.0762 0.0976 0.1207 0.146 0.1744 0.2066 0.2428 0.2827 0.3256 0.3705 0.4165 0.4631 0.5107 0.5602 0.6129 0.6704 0.7334 0.8021 0.8754 0.9518 1.0294 1.1067 1.1834 1.2608 1.3419 1.4318 1.5376 1.6653 1.8213 2.011 2.2382 2.5046 2.8096 3.1494 3.5171 3.8976 4.2687 4.6021 4.8717 5.0727 5.201 5.2687 5.2965 5.3066 5.3189 5.3365 5.3865 5.4558 5.5635 5.7028 5.8633 6.0489 6.2538 6.4708 6.6929 6.914 7.1293 7.3344 7.5209 7.6879 7.8455 7.9974 8.1362 8.2677 8.4072 8.547 8.6955 8.8539 9.025 9.21 9.4099 9.6251 9.8558 10.102 10.362 10.636 10.924 11.224 11.536 11.858 12.189 12.528 12.875 13.229 13.59 13.954 14.323 14.696 15.071 15.447 16.203 16.58 17.089 17.593 18.093 18.588 19.077 19.56 20.036 20.506 20.969 21.424 21.861 22.278 22.683 23.081 23.47 23.856 24.235 24.609 24.98 25.344 25.698 26.037 26.347 26.622 26.87 27.09 27.289 27.459 27.601 27.729 27.849 27.962 28.068 28.158 28.244 28.282 28.272 28.233 28.204 28.181 28.182 28.2 28.21 28.203 28.206 28.181 28.185 28.238 28.346 28.526 28.794 29.158 29.616 30.155 30.753 31.375 31.988 32.556 33.032 33.32 33.435 33.452 33.476 33.597 33.831 34.167 34.581 35.047 35.48 35.784 36.026 36.134 35.959 35.742 35.544 35.466 35.575 35.746 35.995 36.162 36.19 36.11 35.912 35.695 35.529 35.417 35.401 35.464 35.467 35.622 35.747 35.773 35.787 35.827 35.802 35.722 35.596 35.544 35.59 35.687 35.784 35.857 35.867 35.804 35.679 35.462 35.131 34.68 34.179 33.68 33.231 32.833 32.532 32.326 32.18 32.035 31.752 31.265 30.628 29.95 29.221 28.526 27.919 27.419 27.03 26.737 26.542 26.415 26.341 26.301 26.269 26.241 26.212 26.179 26.143 26.102 26.051 25.983 25.892 25.795 25.707 25.636 25.584 25.542 25.502 25.464 25.424 25.362 25.269 25.156 25.013 24.827 24.604 24.343 24.042 23.713 23.361 22.998 22.62 22.229 21.827 21.418 21.004 20.587 20.156 19.72 19.278 18.833 18.385 17.934 17.478 17.018 16.555 16.086 15.614 15.138 14.658 14.175 13.689 13.336 12.982 12.629 12.277 11.926 11.577 11.23 10.887 10.549 10.215 9.8873 9.5665 9.2535 8.9474 8.6508 8.3601 8.0783 7.8076 7.5485 7.2995 7.0654 6.8356 6.6223 6.418 6.2237 6.0401 5.8621 5.6946 5.5356 5.384 5.2382 5.0961 4.9558 4.8113 4.6579 4.5018 4.3427 4.182 4.022 3.8609 3.7051 3.5585 3.4213 3.2873 3.1583 3.032 2.9015 2.7555 2.6037 2.4462 2.284 2.1188 1.9533 1.7903 1.6325 1.4827 1.3435 1.209 1.0844 0.9762 0.8832 0.7952 0.7224 0.6616 0.609 0.5607 0.5128 0.4625 0.4103 0.3567 0.3033 0.2521 0.2051 0.164 0.1295 0.1013 0.0786 0.06 0.0442 0.0304 0.0182 0.0083 0.0019 0 0.0035 0.0125 0.0242 0.0388 0.0564]
and
mGVNnA = [ 1.7 1.1099 0.7069 0.4755 0.2901 0.1465 0.0475 0 0.0014 0.0449 0.1292 0.2868 0.4673 0.7364 1.2223 1.9732 3.0173 4.3603 5.9631 7.7179 9.5019 9.832 8.9113 8.2694 8.0057 8.1343 8.6399 9.5171 10.742 12.285 14.065 16.092 18.473 21.416 25.15 27.353 27.395 26.174 23.967 21.86 20.131 18.734 17.599 16.638 15.887 15.369 15.082 15.024 15.211 15.606 16.196 16.958 17.868 18.867 20 20.151 19.842 19.695 19.725 19.787 19.905 20.082 20.265 20.432 20.595 20.789 21.013 21.281 21.623 22.058 22.536 23.101 23.715 24.38 25.113 25.898 26.737 27.595 28.478 29.381 30.284 31.155 31.971 32.721 33.389 33.969 34.473 34.88 35.237 35.563 35.885 36.251 36.805 37.442 38.143 38.785 39.282 39.452 39.252 38.808 38.293 37.764 37.253 36.773 36.34 35.953 35.634 35.368 35.192 35.093 35.087 35.161 35.305 35.638 35.968 36.19 36.22 36.098 35.797 35.382 35.001 34.788 34.768 34.921 35.411 36.172 36.807 36.485 36.261 35.984 35.618 35.165 34.735 34.498 34.647 35.242 36.268 37.584 38.828 39.695 40.087 40.283 40.635 41.382 42.64 43.356 41.606 40.07 39.359 39.185 39.081 38.836 38.624 38.456 38.255 38.206 38.493 39.266 40.491 41.983 43.328 42.563 40.545 38.503 37.071 36.429 36.194 36.104 35.836 35.579 35.481 35.506 35.707 35.994 36.07 36.031 36.033 36.214 36.667 37.435 38.147 38.873 39.727 40.902 42.706 43.934 43.635 43.926 44.379 44.797 45.114 45.558 46.371 47.239 49.24 52.957 57.002 55.602 53.712 53.855 57.666 52.999 48.404 45.794 44.523 44.54 44.979 45.826 47.281 48.725 49.537 49.035 47.911 45.782 43.136 40.9 39.415 38.682 38.471 38.664 39.083 39.55 39.89 39.954 39.921 40.111 40.907 41.583 41.361 41.264 40.952 40.156 39.005 37.776 36.579 35.531 34.625 33.843 33.158 32.54 32.059 31.661 31.352 31.117 30.908 30.74 30.578 30.447 30.306 30.141 29.997 29.704 29.318 28.964 28.61 28.262 27.903 27.512 27.083 26.622 26.123 25.592 25.037 24.464 23.88 23.292 22.702 22.114 21.537 20.976 20.433 19.985 19.564 19.172 18.811 18.484 18.191 17.938 17.728 17.566 17.458 17.411 17.431 17.437 16.937 16.486 16.093 15.757 15.479 15.269 15.133 15.062 15.072 15.144 15.254 15.407 15.568 15.726 15.86 15.971 16.077 16.2 16.408 16.719 17.174 17.79 18.611 19.673 21.051 22.834 24.971 27.442 29.851 27.032 24.994 23.406 21.624 20.012 18.602 17.435 16.433 15.668 15.115 14.729 14.47 14.339 14.383 14.654 15.252 16.216 14.91 13.992 13.353 12.978 12.89 13.16 13.841 14.942 16.463 18.341 20.559 23.437 26.905 27.021 23.385 19.308 16.1 13.668 11.801 10.36 9.2831 8.5509 8.1662 8.1298 8.4381 7.8963 6.1559 4.6964 3.4785 2.4834 ]
I have no idea which kind of polar plots you are expecting, but the below code may help you to make it as an example.
2D polar plot
% polar plot for G vs. phi, when theta = pi
polar(phi3D, estG(:,length(theta3D)/2+1));
hold on;
% polar plot for G vs. theta, when phi = pi
polar(theta3D, estG(length(phi3D)/2+1,:));
legend("G vs. phi #(theta=pi)","G vs. theta #(phi=pi)");
title("2D radiation pattern");
hold off;
- 3D polar plot
[X, Y] = meshgrid (theta3D, phi3D);
surf(X,Y,estG,'LineStyle','none');
xlabel("theta");
ylabel("phi");
zlabel("G");
colormap("jet");
colorbar
The code that you have included does generate an estimate of gain vs theta and phi, however, you are plotting it on rectangular coordinates. if you noticed, in the resultant figure, the x and y axes are ranging from 0 to 2pi.
you created a (theta, phi, magnitude) data set, and need to convert that to an x,y,z data set.
doing a coordinate transformation, similar to:
xconv = estG.*sin(theta3D).*cos(phi3D);
yconv = estG.*sin(theta3D).*sin(phi3D);
zconv = estG.*cos(theta3D);
may give you what you need.
surf(xconv,yconv,zconv,'Edgecolor','none')
produces:
Since I'm not exactly sure what output would be correct from this data, I can't tell if that quite has it. There may be some ordering issues with mesh and surf plot data that i'm not aware of.
I recommend always starting simple. Work with a unit gain omnidirectional antenna, and see if your process above can go from two circle plots to a sphere. then generate more complex patterns.
for reference, here's a decent set of classroom exercises on 3D parametric plots

What is the format of "{123, affdsf, 223, 22, dgbwa, 33333}"?

I have the following format, please advise how to convert it to a list in R?
"{1948, 2507, 2510, 7030, 7110, 9009, 00027, 00206, 00399, 00717, 00814, 00828, 00848, 00917, 01050, 01105, 01144, 02130, 02768, 03037, 03752, 03754, 04070, 04110, 05050, 05255, 05289, 05564, 05595, 06100, 06330, 06671, 07041, 07119, 07137, 07273, 07313, 07454, 07871, 08104, 08714, 08726, 08995, 09059, 09073, 09525, 09949, 09981, 10092, 10439, 10782, 11185, 11507, 11712, 11806, 11858, 11980, 12067, 12113, 12139, 12643, 13820, 14534, 15007, 15014, 15549, 15953, 16151, 16174, 16634, 16733, 16888, 17111, 17207, 17377, 17721, 17900, 18118, 18400, 18686, 18880, 19080, 19342, 19444, 19772, 19790, 19891, 20091, 20245, 20402, 20811, 21114, 21345, 21811, 21881, 22222, 22311, 22320, 22831, 22969, 23251, 23572, 23734, 23862, 23889, 24034, 24463, 25172, 25688, 26143, 26221, 26803, 26850, 26898, 27497, 28291, 28343, 29411, 29419, 30024, 30561, 30923, 31345, 31351, 31555, 31927, 32198, 32861, 33020, 33040, 33095, 33188, 33311, 33368, 33377, 33475, 33519, 33574, 33592, 34207, 34235, 34272, 34484, 34854, 34872, 34875, 34876, 34880, 35222, 35292, 35344, 36177, 36266, 37038, 37060, 37548, 37686, 37700, 38139, 39368, 39369, 39633, 40132, 40698, 40704, 40744, 40819, 41311, 41971, 42102, 42616, 43055, 43211, 43234, 43428, 43494, 43934, 44117, 44252, 44272, 44301, 44336, 44619, 44866, 44888, 45049, 45197, 45412, 45718, 46694, 46736, 47000, 48046, 48540, 49078, 49109, 49216, 49388, 49464, 50056, 50155, 50217, 50477, 50692, 51122, 51445, 51946, 52475, 52537, 52982, 54011, 54031, 54160, 54963, 55000, 55537, 56080, 56163, 56282, 56760, 56787, 57102, 57727, 57871, 58101, 58558, 58882, 59902, 60225, 60397, 60501, 60619, 60703, 60890, 61075, 61894, 61944, 62322, 62337, 62380, 62413, 62729, 62766, 62923, 63010, 63234, 63977, 64127, 65359, 65428, 65542, 65750, 65863, 66184, 66636, 66712, 67201, 67439, 67953, 68133, 68854, 69251, 69959, 70107, 70725, 70768, 71081, 71099, 71948, 72013, 72377, 72400, 72420, 72735, 73000, 73015, 73142, 73223, 73455, 73717, 74049, 74492, 74854, 74941, 75142, 75399, 75464, 75587, 75618, 75642, 75887, 76357, 76651, 77199, 77302, 77456, 77579, 77601, 77649, 77668, 77694, 77745, 78006, 78010, 78178, 78335, 78656, 78729, 78808, 78824, 78844, 78945, 79416, 79471, 79915, 80077, 80111, 80189, 80262, 80409, 80470, 80529, 80539, 80838, 81272, 81513, 81658, 81740, 81743, 81762, 81843, 82001, 82070, 82106, 82342, 82472, 82719, 83670, 84009, 84151, 84299, 84430, 84450, 84460, 84945, 86411, 86443, 86446, 86668, 86942, 87286, 87317, 87624, 87785, 88023, 88517, 88696, 88787, 88868, 88977, 89206, 90108, 90440, 90734, 90802, 90849, 90920, 90931, 91011, 91031, 91133, 91777, 91949, 92162, 92494, 93012, 93172, 94300, 94517, 95142, 95410, 95559, 95859, 96112, 97255, 97787, 97986, 98240, 98817, 99050, 99198, 99222, 99241, 99295, 99326, 99335, 99503, 99603, 99643, 99803, 99968}"
THIS IS NOT A DUPLICATE OF convert json to list in a vectorized way in R
IT'S COMPLETELY DIFFERENT BECAUSE THE FORMAT IS ABSOLUTELY DIFFERENT.
Try this one line code:
as.numeric(sapply(strsplit(substr(j,2,nchar(j)-1),split = ","),trimws))
[1] 1948 2507 2510 7030 7110 9009 27 206 399 717 814 828 848 917 1050 1105 1144
[18] 2130 2768 3037 3752 3754 4070 4110 5050 5255 5289 5564 5595 6100 6330 6671 7041 7119
[35] 7137 7273 7313 7454 7871 8104 8714 8726 8995 9059 9073 9525 9949 9981 10092 10439 10782
[52] 11185 11507 11712 11806 11858 11980 12067 12113 1213 ..
Your input:
j<-"{1948, 2507, 2510, 7030, 7110, 9009, 00027, 00206, 00399, 00717, 00814, 00828, 00848, 00917, 01050, 01105, 01144, 02130, 02768, 03037, 03752, 03754, 04070, 04110, 05050, 05255, 05289, 05564, 05595, 06100, 06330, 06671, 07041, 07119, 07137, 07273, 07313, 07454, 07871, 08104, 08714, 08726, 08995, 09059, 09073, 09525, 09949, 09981, 10092, 10439, 10782, 11185, 11507, 11712, 11806, 11858, 11980, 12067, 12113, 12139, 12643, 13820, 14534, 15007, 15014, 15549, 15953, 16151, 16174, 16634, 16733, 16888, 17111, 17207, 17377, 17721, 17900, 18118, 18400, 18686, 18880, 19080, 19342, 19444, 19772, 19790, 19891, 20091, 20245, 20402, 20811, 21114, 21345, 21811, 21881, 22222, 22311, 22320, 22831, 22969, 23251, 23572, 23734, 23862, 23889, 24034, 24463, 25172, 25688, 26143, 26221, 26803, 26850, 26898, 27497, 28291, 28343, 29411, 29419, 30024, 30561, 30923, 31345, 31351, 31555, 31927, 32198, 32861, 33020, 33040, 33095, 33188, 33311, 33368, 33377, 33475, 33519, 33574, 33592, 34207, 34235, 34272, 34484, 34854, 34872, 34875, 34876, 34880, 35222, 35292, 35344, 36177, 36266, 37038, 37060, 37548, 37686, 37700, 38139, 39368, 39369, 39633, 40132, 40698, 40704, 40744, 40819, 41311, 41971, 42102, 42616, 43055, 43211, 43234, 43428, 43494, 43934, 44117, 44252, 44272, 44301, 44336, 44619, 44866, 44888, 45049, 45197, 45412, 45718, 46694, 46736, 47000, 48046, 48540, 49078, 49109, 49216, 49388, 49464, 50056, 50155, 50217, 50477, 50692, 51122, 51445, 51946, 52475, 52537, 52982, 54011, 54031, 54160, 54963, 55000, 55537, 56080, 56163, 56282, 56760, 56787, 57102, 57727, 57871, 58101, 58558, 58882, 59902, 60225, 60397, 60501, 60619, 60703, 60890, 61075, 61894, 61944, 62322, 62337, 62380, 62413, 62729, 62766, 62923, 63010, 63234, 63977, 64127, 65359, 65428, 65542, 65750, 65863, 66184, 66636, 66712, 67201, 67439, 67953, 68133, 68854, 69251, 69959, 70107, 70725, 70768, 71081, 71099, 71948, 72013, 72377, 72400, 72420, 72735, 73000, 73015, 73142, 73223, 73455, 73717, 74049, 74492, 74854, 74941, 75142, 75399, 75464, 75587, 75618, 75642, 75887, 76357, 76651, 77199, 77302, 77456, 77579, 77601, 77649, 77668, 77694, 77745, 78006, 78010, 78178, 78335, 78656, 78729, 78808, 78824, 78844, 78945, 79416, 79471, 79915, 80077, 80111, 80189, 80262, 80409, 80470, 80529, 80539, 80838, 81272, 81513, 81658, 81740, 81743, 81762, 81843, 82001, 82070, 82106, 82342, 82472, 82719, 83670, 84009, 84151, 84299, 84430, 84450, 84460, 84945, 86411, 86443, 86446, 86668, 86942, 87286, 87317, 87624, 87785, 88023, 88517, 88696, 88787, 88868, 88977, 89206, 90108, 90440, 90734, 90802, 90849, 90920, 90931, 91011, 91031, 91133, 91777, 91949, 92162, 92494, 93012, 93172, 94300, 94517, 95142, 95410, 95559, 95859, 96112, 97255, 97787, 97986, 98240, 98817, 99050, 99198, 99222, 99241, 99295, 99326, 99335, 99503, 99603, 99643, 99803, 99968}"
This code removes first and last character of the string ("{" and "}" characters), splits values by "," and removes whitespaces using trimws. After that it moves the format to number.
If it happens your data actually is json, stick with the rjson package. This answer is assuming your data is not json (since rjson::fromjson throws an error on your data)
Try:
string <- "{1948, 2507, 2510, 7030, 7110, 9009, 00027, 00206, 00399, 00717, 00814, 00828, 00848, 00917, 01050, 01105, 01144, 02130, 02768, 03037, 03752, 03754, 04070, 04110, 05050, 05255, 05289, 05564, 05595, 06100, 06330, 06671, 07041, 07119, 07137, 07273, 07313, 07454, 07871, 08104, 08714, 08726, 08995, 09059, 09073, 09525, 09949, 09981, 10092, 10439, 10782, 11185, 11507, 11712, 11806, 11858, 11980, 12067, 12113, 12139, 12643, 13820, 14534, 15007, 15014, 15549, 15953, 16151, 16174, 16634, 16733, 16888, 17111, 17207, 17377, 17721, 17900, 18118, 18400, 18686, 18880, 19080, 19342, 19444, 19772, 19790, 19891, 20091, 20245, 20402, 20811, 21114, 21345, 21811, 21881, 22222, 22311, 22320, 22831, 22969, 23251, 23572, 23734, 23862, 23889, 24034, 24463, 25172, 25688, 26143, 26221, 26803, 26850, 26898, 27497, 28291, 28343, 29411, 29419, 30024, 30561, 30923, 31345, 31351, 31555, 31927, 32198, 32861, 33020, 33040, 33095, 33188, 33311, 33368, 33377, 33475, 33519, 33574, 33592, 34207, 34235, 34272, 34484, 34854, 34872, 34875, 34876, 34880, 35222, 35292, 35344, 36177, 36266, 37038, 37060, 37548, 37686, 37700, 38139, 39368, 39369, 39633, 40132, 40698, 40704, 40744, 40819, 41311, 41971, 42102, 42616, 43055, 43211, 43234, 43428, 43494, 43934, 44117, 44252, 44272, 44301, 44336, 44619, 44866, 44888, 45049, 45197, 45412, 45718, 46694, 46736, 47000, 48046, 48540, 49078, 49109, 49216, 49388, 49464, 50056, 50155, 50217, 50477, 50692, 51122, 51445, 51946, 52475, 52537, 52982, 54011, 54031, 54160, 54963, 55000, 55537, 56080, 56163, 56282, 56760, 56787, 57102, 57727, 57871, 58101, 58558, 58882, 59902, 60225, 60397, 60501, 60619, 60703, 60890, 61075, 61894, 61944, 62322, 62337, 62380, 62413, 62729, 62766, 62923, 63010, 63234, 63977, 64127, 65359, 65428, 65542, 65750, 65863, 66184, 66636, 66712, 67201, 67439, 67953, 68133, 68854, 69251, 69959, 70107, 70725, 70768, 71081, 71099, 71948, 72013, 72377, 72400, 72420, 72735, 73000, 73015, 73142, 73223, 73455, 73717, 74049, 74492, 74854, 74941, 75142, 75399, 75464, 75587, 75618, 75642, 75887, 76357, 76651, 77199, 77302, 77456, 77579, 77601, 77649, 77668, 77694, 77745, 78006, 78010, 78178, 78335, 78656, 78729, 78808, 78824, 78844, 78945, 79416, 79471, 79915, 80077, 80111, 80189, 80262, 80409, 80470, 80529, 80539, 80838, 81272, 81513, 81658, 81740, 81743, 81762, 81843, 82001, 82070, 82106, 82342, 82472, 82719, 83670, 84009, 84151, 84299, 84430, 84450, 84460, 84945, 86411, 86443, 86446, 86668, 86942, 87286, 87317, 87624, 87785, 88023, 88517, 88696, 88787, 88868, 88977, 89206, 90108, 90440, 90734, 90802, 90849, 90920, 90931, 91011, 91031, 91133, 91777, 91949, 92162, 92494, 93012, 93172, 94300, 94517, 95142, 95410, 95559, 95859, 96112, 97255, 97787, 97986, 98240, 98817, 99050, 99198, 99222, 99241, 99295, 99326, 99335, 99503, 99603, 99643, 99803, 99968}"
string as list of characters:
string_as_list_char <- as.list(strsplit(gsub('\\{|\\}', '', string), ", "))[[1]]
or converted to numeric:
string_as_list_num <- as.list(as.numeric(strsplit(gsub('\\{|\\}', '', string), ", ")[[1]]))

Unexpected error using Jump with Julia

I am trying to solve an optimization problem, I am getting error as
"ERROR: Expected m to be a JuMP model, but it has type Int64
in validmodel(::Int64, ::Symbol) at C:\Users\Ting.julia\v0.5\JuMP\src\macros.jl:247
in macro expansion; at C:\Users\Ting.julia\v0.5\JuMP\src\macros.jl:252 [inlined]
in macro expansion; at .\REPL[608]:3 [inlined]
in anonymous at .\:?"
Please see the following code(error in constraint 2). Please don't mind the way I have defined arrays, any help is appreciated. Thank you
using JuMP
using Gurobi
m = Model(solver = GurobiSolver()) #if GurobiSolver is to be used .
## insert all matrixs here
#this is the cost for plant to warehouse
plant=4 #last index for {1,2,3}
product=5 #ast index for {2,3,4}
customer=50
warehouse=4
#variable(m, x[i=1:product ,k=1:plant,l=1:warehouse]>=0) #plant to warehouse
#variable(m, y[i=1:product ,k=1:warehouse,l=1:customer]>=0) #warehouse to customer
#variable(m, z[i=1:product ,k=1:plant,l=1:customer ]>=0) #plant to customer
#variable(m, p[i=1:product ,k=1:plant]>=0) #any product i produced at plant k
#THIS GIVES COST OF PRODUCING AT ANY PRODUCT I AT PLANT K
PC=[500 500 500 500;
400 400 400 400;
300 300 300 300;
200 200 200 200;
100 100 100 100]
#DEMAND OF I AT ANY COSTOMER M, SHOULD BE A MATRIX OF (5*50)
D=[4650.28 10882.70 7920.68 2099.06 4920.32 5077.80 2259.10 9289.30 9782.28 4671.85 6625.68 6956.80 5288.12 4144.78 11121.56 9152.47 10206.88 4601.63 2718.91 1439.39 2984.38 3631.17 3934.48 12314.28 4188.04 8437.43 6302.34 1248.62 6286.56 7333.46 11027.86 6233.33 7240.82 5652.13 10276.03 1197.22 11160.13 4510.31 8850.49 8291.09 1081.47 7652.23 3936.85 2640.47 7726.72 1422.96 1644.78 1060.39 6858.66 6554.45;
528.11 4183.80 352.45 366.34 1961.78 3419.11 337.44 708.15 3556.56 1649.95 583.25 1525.97 1569.92 349.93 1904.59 2221.80 2139.63 1822.87 546.11 784.93 948.33 1424.26 1910.64 2275.11 1527.57 2477.49 1592.14 90.86 2635.48 131.02 2402.35 2669.67 105.34 1350.60 4233.60 411.54 687.88 89.09 213.23 2817.29 8.08 1586.51 577.07 1529.34 2919.06 393.97 85.45 214.93 3193.94 1565.64;
480.26 622.67 131.04 14.45 1299.71 599.27 83.08 197.37 1986.77 409.08 371.12 1249.92 216.21 62.43 34.96 1752.75 227.06 184.26 219.92 577.37 138.71 36.23 1659.02 1323.50 236.64 2557.64 76.74 74.08 363.64 52.96 456.67 1589.86 81.89 617.11 509.86 145.52 14.13 83.22 215.03 2749.34 7.12 490.00 120.42 456.03 430.22 165.02 66.16 150.70 2806.58 1403.70;
307.36 474.39 7.56 11.76 882.03 222.62 27.29 158.13 55.94 332.98 171.36 492.81 44.12 24.08 15.57 739.97 11.09 199.51 136.46 194.40 63.72 2.42 355.99 1005.42 66.33 1647.51 47.22 21.32 218.06 11.54 305.81 387.71 8.50 248.38 9.20 76.05 13.12 39.83 146.52 379.44 2.75 239.53 94.06 136.96 290.16 237.75 9.04 110.64 842.58 395.08;
76.52 280.62 5.06 6.75 281.41 215.58 5.78 54.69 20.79 22.08 78.50 322.13 34.13 6.37 11.66 178.33 3.40 142.11 60.70 46.17 6.96 1.15 227.70 669.39 3.21 526.85 45.91 17.00 131.43 11.19 189.00 43.93 3.36 110.66 1.75 41.34 0 38.63 50.78 241.19 0 176.32 94.25 99.59 153.50 123.02 3.76 122.52 853.48 99.62]
a = Array{Float64}(5,4,4)
a[1,1,1]=a[2,1,1]=a[3,1,1]=a[4,1,1]=a[5,1,1]=0.2*528.42
a[1,2,1]=a[2,2,1]=a[3,2,1]=a[4,2,1]=a[5,2,1]=0.2*1366.16
a[1,3,1]=a[2,3,1]=a[3,3,1]=a[4,3,1]=a[5,3,1]=0.2*1525.41
a[1,4,1]=a[2,4,1]=a[3,4,1]=a[4,4,1]=a[5,4,1]=0.2*878.11
a[1,1,2]=a[2,1,2]=a[3,1,2]=a[4,1,2]=a[5,1,2]=0.2*1692.25
a[1,2,2]=a[2,2,2]=a[3,2,2]=a[4,2,2]=a[5,2,2]=0.2*1553.06
a[1,3,2]=a[2,3,2]=a[3,3,2]=a[4,3,2]=a[5,3,2]=0.2*817.18
a[1,4,2]=a[2,4,2]=a[3,4,2]=a[4,4,2]=a[5,4,2]=0.2*2164.69
a[1,1,3]=a[2,1,3]=a[3,1,3]=a[4,1,3]=a[5,1,3]=0.2*2006.5
a[1,2,3]=a[2,2,3]=a[3,2,3]=a[4,2,3]=a[5,2,3]=0.2*1385.04
a[1,3,3]=a[2,3,3]=a[3,3,3]=a[4,3,3]=a[5,3,3]=0.2*998.58
a[1,4,3]=a[2,4,3]=a[3,4,3]=a[4,4,3]=a[5,4,3]=0.2*2148.45
a[1,1,4]=a[2,1,4]=a[3,1,4]=a[4,1,4]=a[5,1,4]=0.2*1073.07
a[1,2,4]=a[2,2,4]=a[3,2,4]=a[4,2,4]=a[5,2,4]=0.2*368.35
a[1,3,4]=a[2,3,4]=a[3,3,4]=a[4,3,4]=a[5,3,4]=0.2*450.12
a[1,4,4]=a[2,4,4]=a[3,4,4]=a[4,4,4]=a[5,4,4]=0.2*1129.27
#objective(m, Min ,sum(a[i,k,l]* x[i,k,l] for i=1:product for k=1:plant for l=1:warehouse) + sum(c_dash[i,l,m]* y[i,l,m] for i=1:product for l=1:warehouse for m=1:plant) +sum(c_dash_dash[i,k,m]* z[i,k,m] for i=1:product for k=1:plant for m=1:customer)+sum(PC[i,k]* p[i,k] for i=1:product for k=1:plant)) #to be changes
#constraint(m,p[1,2]==0)
#constraint(m,p[1,3]==0)
#constraint(m,p[1,4]==0)
#constraint(m,p[2,1]==0)
#constraint(m,p[2,3]==0)
#constraint(m,p[2,4]==0)
#constraint(m,p[3,1]==0)
#constraint(m,p[3,2]==0)
#constraint(m,p[3,4]==0)
#constraint(m,p[4,1]==0)
#constraint(m,p[4,2]==0)
#constraint(m,p[4,3]==0)
#constraint(m,p[5,1]==0)
#constraint(m,p[5,2]==0)
#constraint(m,p[5,3]==0)
#constraint(m,p[1,1]<=450000)
#constraint(m,p[2,2]<=108000)
#constraint(m,p[3,3]<=45000)
#constraint(m,p[4,4]<=18000)
#constraint(m,p[5,4]<=9000)
#constraint 1
#constraint(m,415728.69-0.8* sum(y[i,l,m] for i=1:product for l=1:warehouse for m=1:customer) <=0)
#constrainst 2
for m=1:customer
for i=1:product
#constraint(m, D[i,m]-sum(z[i,k,m] for k=1:plant)-sum(y[i,l,m] for l=1:warehouse) <=0 ) #cant get
end
end
#constrainst 2
for m=1:customer
for i=1:product
#constraint(m, D[i,m]-sum(z[i,k,m] for k=1:plant)-sum(y[i,l,m] for l=1:warehouse) <=0 ) #cant get
end
end
The error explains the problem very well. Your outer-loop variable here is m, which makes usage of m inside the loop refers to the loop variable and not to your model. m is also used to hold the model in the outer-scope. Change your loop variable or model variable to something else and the problem is fixed.

Resources