[R] Spline Question

Hasan Diwan hasan.diwan at gmail.com
Tue Feb 14 22:14:10 CET 2012


> dput(sensor.sample)
structure(c(1328565718.65, 1328566608.9, 1328566162.65, 1328566571.1,
1328566598.85, 1328565634.3, 1328566513.95, 1328565123.65, 1328565827.1,
1328566719.9, 1328565527.55, 1328565118.05, 1328565556.85, 1328565623.85,
1328565230.75, 1328566083.85, 1328566012.45, 1328566795.75, 1328565262.85,
1328566191.35, 1328565827.8, 1328566384.25, 1328565376.95, 1328566006.8,
1328566570.05, 1328565570, 1328565916.6, 1328566915.35, 1328565693.05,
1328566849.5, 1328565591.55, 1328565161.55, 1328566854.75, 1328566697.1,
1328566807.7, 1328565764.6, 1328565545.3, 1328566294.5, 1328566900.1,
1328566583.1, 1328566114.65, 1328565407.35, 1328566168.05, 1328565560.55,
1328565310.9, 1328565523.45, 1328566256.55, 1328566751.15, 1328565915.5,
1328565945.3, 1328565814.35, 1328566076.3, 1328565793.55, 1328565680.55,
1328566642.8, 1328565417.55, 1328566806.45, 1328566174.2, 1328566692.85,
1328565409.2, 1328566878.25, 1328565824, 1328566747.95, 1328566569.2,
1328566781.5, 1328566408.35, 1328566267.05, 1328566031.15, 1328566758.35,
1328565973.6, 1328566718, 1328566176.5, 1328565351.5, 1328565443.4,
1328565119.65, 1328565134.9, 1328566771, 1328565589, 1328566621.05,
1328565096.2, 1328566427.05, 1328566122.15, 1328565815.65, 1328566352.8,
1328566432, 1328566943.5, 1328566807.25, 1328565701.15, 1328566496.4,
1328565461.7, 1328565331.65, 1328565853.85, 1328565757.1, 1328566760.75,
1328565823.85, 1328566728.2, 1328566586.75, 1328565387.65, 1328565734.6,
1328565377.95, 1328566264.2, 1328565783.75, 1328566498.65, 1328565179.3,
1328565481.8, 1328565562.9, 1328565256.9, 1328566797.9, 1328566244.25,
1328565600.75, 1328566407.6, 1328566061.5, 1328566122.35, 1328565930.8,
1328565306.55, 1328565323.55, 1328565401.9, 1328565454.3, 1328566016.65,
1328566627.2, 1328566683.45, 1328566251.65, 1328565110.8, 1328565600.95,
1328565067.2, 1328565476.55, 1328565987.35, 1328566491.85, 1328566170.15,
1328565781.55, 1328566931, 1328565904.65, 1328566650.35, 1328565598.9,
1328566353.75, 1328566522.4, 1328565898.85, 1328565676.85, 1328566563.1,
1328565671.05, 1328565107.45, 1328565872.6, 1328565417.45, 1328565575.9,
1328565685.65, 1328566090.9, 1328566208.75, 1328566393.45, 1328565468.25,
1328565761.35, 1328566691.3, 1328565834.4, 1328565677.9, 1328566502.6,
1328566861.75, 1328566189.3, 1328565953.25, 1328566378.75, 1328565684.75,
1328565505.55, 1328565862.55, 1328565475.15, 1328566436.65, 1328566075.35,
1328566405, 1328565732.4, 1328566813.7, 1328566316.9, 1328565333.6,
1328565845.55, 1328565067.15, 1328565793.5, 1328566779.55, 1328565920.8,
1328565224.15, 1328566109.55, 1328565718.1, 1328565167.05, 1328565569.4,
1328565712, 1328565457.45, 1328565787.15, 1328566688.75, 1328565955.35,
1328565071.65, 1328566758.6, 1328566224.65, 1328566241.8, 1328565577.15,
1328565915.65, 1328566746.65, 1328566529.25, 1328565608, 1328566423.5,
1328566679.75, 1328566209.25, 1328565187.05, 1328565999.1, 1328565900.05,
1328565788.3, 1328565416.3, 1328565825.5, 1328566934.8, 1328565293.9,
1328566320.45, 1328566359.25, 1328566768.2, 1328565884, 1328566709.8,
1328565500.15, 1328565407.25, 1328565310.15, 1328566339.25, 1328565325.2,
1328565657.65, 1328566649.95, 1328565668.4, 1328566041.05, 1328565353.85,
1328565555.8, 1328565160.45, 1328566730.2, 1328565463.6, 1328565367.3,
1328565871.65, 1328566409.3, 1328565188.95, 1328565697.3, 1328566938.3,
1328566896.85, 1328565814.15, 1328565786.65, 1328565651.4, 1328566027.7,
1328565577.55, 1328565833.1, 1328565565.05, 1328566055.5, 1328565797.3,
1328566736.4, 1328565117.1, 1328565278.05, 1328565453.3, 1328566725.8,
1328566609.7, 1328565200.7, 1328566554.8, 1328565170.2, 1328565926.05,
1328566840.8, 1328565313.55, 1328566225.35, 1328565366.1, 1328565183.25,
1328566261.8, 1328565673.55, 1328566884.8, 1328566264.65, 1328565216.35,
1328566879.4, 1328566720, 1328565767.1, 1328566113.35, 1328565657.05,
1328566331.9, 1328565554.05, 1328565239.25, 1328565124.6, 1328565789.65,
1328566444.9, 1328565532.2, 1328566719.35, 1328565205.45, 1328566617.45,
1328565708.85, 1328566155.35, 1328565977.55, 1328566142, 1328566342.25,
1328565232.15, 1328566016.7, 1328565895.85, 1328566345.35, 1328566500.7,
1328566403.5, 1328566895.45, 1328565636.5, 1328565809.75, 1328565537.05,
1328566369.45, 1328566340.4, 1328565180, 1328565641.05, 1328565204,
1328566082.05, 1328566183.9, 1328566527.1, 1328566667.85, 1328566297.2,
1328566094.65, 1328565577.45, 1328566841.05, 1328566422.05, 1328565968.4,
1328566527.5, 1328565450.85, 1328565194.3, 1328565859.05, 1328565790.7,
1328566536.05, 1328565555.05, 1328566847.6, 1328566431.85, 1328565081.7,
1328565942.8, 1328566154.7, 1328565312.55, 1328565370.95, 1328565222.9,
1328566301.45, 1328565861.2, 1328565974.6, 1328566650.85, 1328566048.4,
1328565780.1, 1328566022.3, 1328566136, 1328566030.75, 1328566877.05,
1328566552.6, 1328565647.2, 1328565181.65, 1328565565.3, 1328566545.1,
1328565860.75, 1328566520.7, 1328565431.65, 1328566769.5, 1328565816.6,
1328565257.75, 1328566903.45, 1328565080.15, 1328565737.4, 1328566865.05,
1328565100.05, 1328565818.6, 1328565075.6, 1328565435.85, 1328565478.85,
1328566120.75, 1328566573.2, 1328566055.1, 1328566616.1, 1328566181.55,
1328566688.05, 1328566617.9, 1328565260.9, 1328565662.6, 1328566418.1,
1328566166.75, 1328566620.75, 1328566146.95, 1328566743.3, 1328565810.25,
1328566775.25, 1328566735.15, 1328565500.7, 1328566116.55, 1328565996.7,
1328565696.35, 1328565962.8, 1328565466.55, 1328566416.75, 1328566400.4,
1328566019.9, 1328565380.65, 1328565826.75, 1328565450.3, 1328566017.35,
1328565748.15, 1328565758.6, 1328566195.05, 1328566258.15, 1328565130.5,
1328566616.7, 1328565702.5, 1328565642.5, 1328566431.65, 1328566621.8,
1328566377.65, 1328565199, 1328566880.9, 1328566470.4, 1328566325.7,
1328566754.25, 1328565385.15, 1328565898.35, 1328566186.05, 1328565530.6,
1328566667, 1328565499.65, 1328566090.35, 1328566582.25, 1328566695.4,
1328566105.6, 1328565442.2, 1328565534.55, 1328566669.35, 1328565595.8,
1328565292.3, 1328566155.1, 1328566585.05, 1328566251.4, 1328565394.75,
1328565994.1, 1328565887.55, 1328566949.55, 1328565429, 1328565116.45,
1328565263.35, 1328565792, 1328566074.25, 1328565942.65, 1328565769.3,
1328565446.35, 1328566787.95, 1328566470.5, 1328566484.05, 1328566576.35,
1328566530.35, 1328565877.4, 1328566322.95, 1328565929.1, 1328565345.1,
1328566326.95, 1328565100.35, 1328565428.1, 1328565501.3, 1328565462.8,
1328566105.8, 1328566125.85, 1328566246.75, 1328566011.1, 1328566597.65,
1328565435.6, 1328566559.8, 1328565684.15, 1328566859.85, 1328565822.65,
1328565779.75, 1328565371.25, 1328565890.95, 1328565842.5, 1328566440.2,
1328566757.75, 1328565710.25, 1328565177.75, 1328566477.55, 1328566048.65,
1328566861.2, 1328566476.8, 1328566631.3, 1328566087, 1328565395.85,
1328565628.25, 1328566917.8, 1328565401.05, 1328565932.45, 1328565613.15,
1328566823.6, 1328565615.85, 1328565418.2, 1328565089.55, 1328566944.35,
1328566473.65, 1328566529.95, 1328566343.3, 1328566555.4, 1328565976.5,
1328565587.35, 1328566461.75, 1328566401.2, 1328565192.25, 1328566671,
1328566593.35, 1328566172.8, 1328566287.7, 1328565326.15, 1328565682.5,
1328566864.35, 1328565950.95, 1328565397.1, 1328565462, 1328566475.25,
1328566154.15, 1328565511.9, 1328565348.25, 1328565184.55, 1328565831.35,
1328565677.5, 1328565718.65, 1328566608.9, 1328566162.65, 1328566571.1,
0.058568910563872, 0.0511868450318788, -0.135411475909466, 0.00932422732948436,
0.0221895355387284, 0.0266546646856788, 0.0225434123181202, 0.0445814605816278,
0.0149059096898036, 0.013002613503818, -0.00148695446444385,
0.0162925217394799, 0.194031458115288, 0.0138304305434145, -0.0266180500206368,
-0.00646911596246798, -0.0412701924232419, -0.0238272088404772,
-0.0137342564676858, 0.0797856146954829, -0.90478895075067, -0.774579497337121,
0.71159944326151, -0.573210178957945, 1.00423557840065, 1.08090898779486,
-0.90317224512971, -0.837349518268004, -0.450305661106175, 0.482263537821871,
-0.210635196657228, 1.06625146841772, 0.593861172390831, 0.901620711539,
-0.253816546115667, -0.314212683559678, -1.06770559734598, -1.06191372338235,
-1.01138431809699, 0.705412483726089, -0.697933444547738, 1.04980715654539,
-0.735937543288563, 0.721557188693841, -0.768012806319571, -0.0777548978795496,
0.315020281992728, -0.849241844084207, 0.45449975476056, 0.653141808264299,
-0.789914644411014, -1.09799603177767, -1.01654703343151, 0.479698068834095,
-0.932039138545532, -1.02125365829574, 0.951793541615827, -0.25229904168921,
-0.642807866829154, -1.06309819341136, -0.587332309206754, 0.772132328844058,
-0.727999563261546, -0.355800870669285, 0.434419520315897, 0.717798148885061,
-1.3026058899525, -0.200775741352829, -0.722195720331664, 0.30015599883479,
1.61824255453618, -0.869639161255852, 0.780867758891911, 0.879713526126198,
0.388334466425829, 0.414881116390536, 0.363325667548522, -0.736202714214622,
0.634135620090881, 0.556627979904911, -0.568147573667465, -0.0341425432385417,
-0.00804091144955306, 0.627625849668855, 0.304192943075762,
-0.0689459842358459,
-0.639599229935383, 0.342878535857593, -0.917759386607326, -0.224155843478268,
0.980262300673151, -0.604089453101234, 1.08857424128453, -0.586265982634391,
1.35392252120102, 0.0173836460807213, 0.179425711032319, 0.0379287381705657,
0.454146431073444, -0.738895905711667, 0.923764045662447, 0.436405296331115,
0.963237504972331, -0.451375772556388, 0.828480794594088, 0.6211723348465,
1.09819757687974, 0.465105068138113, -1.0080060339165, -0.96346001030443,
0.764245337609077, -3.97971524329465, -1.23537433715641, -1.55297781372654,
-0.3237450934937, 0.280052954627322, -0.864349045454991, 0.547078278264985,
0.205210237304801, 0.429092984971821, 0.165784200842805, -1.10628433893369,
1.72173744231242, -0.664132942230383, 0.16382414077999, -1.34273917046151,
1.20459435954894, -0.458399281334183, -0.131687787366378, -0.365735332724749,
1.06446355403877, 0.7520292831953, 0.139426114181465, 0.324511354895922,
0.990090697161268, 0.58086017793929, 1.1094386500677, -0.377509504954366,
0.336057049042523, 0.0815644379489825, -0.194619572368706, -0.73866230798328,
-0.207779210106598, -0.223365320735301, -0.902579771425499, -1.06348829607545,
-1.04262048135017, 0.905081346884576, 0.978232638890445, 0.318456309466711,
-0.46584235623236, -1.32920267437448, -1.01078041309503, -1.0190939850044,
0.596945306128167, 0.039248776884906, 0.470908352355763, 0.242227669336369,
-0.794667498711786, 0.849610924087857, 0.98209977967158, 0.221035936691016,
1.03254999954335, -0.956170165132077, -1.07366977186396, -0.916589711558596,
-0.929903013689476, 0.172892846566435, 0.903187173351947, -0.048346526669085,
1.10313525888536, 0.526905159383735, 0.193226522096174, 0.227300860384115,
0.958509060853982, -1.0962273353809, -1.05032921679915, -0.551540994545707,
-0.303534647709995, 0.591564184570151, 0.898014736391722, -0.720521223132952,
-0.627438899894582, -0.408663392251694, 0.991165330462328, 1.04179806551297,
-1.0069680112654, 0.682692493403403, 0.470265009993306, 1.07641428208565,
-0.89507075544131, 1.01423239437075, 1.280013753532, -0.224947358383339,
0.757522359915101, -0.190791448498627, -0.981750755785834, -0.723454819614721,
-0.419434773939834, 0.99794821035058, -0.189154692568339, 1.03170588239378,
0.931103634476647, -0.041650514784782, 0.823118636277549, -0.116839227710502,
1.03791799837854, 0.304012213744609, 1.03759114318448, -0.223329015235008,
-0.0962636467352087, 0.691583681273164, 0.833587154601568, 0.985046441959357,
-0.342838713698308, -1.26159612687724, -0.880475894801445, 0.2977423996543,
-1.12820569810033, 0.333941000699571, 0.164230825678212, -0.00710198880648841,
-0.92740591582959, 1.26889381258255, -0.681566589451224, -0.318236315757026,
-0.87104711414855, 1.13399706406765, 0.634673075856841, 0.318653101599163,
1.14484101251231, 0.414169876283701, -1.01103228053149, 0.549912527843941,
-0.884388086523523, 0.644022010422799, -0.118707620443655, 0.112483112988214,
-0.638120057120857, 0.916599669145912, -0.562132619400381, -0.257533914813096,
-0.979757981345907, 0.570516463626472, -0.638830664473649, 0.291824118949727,
1.01899575380805, -0.0599671352216299, -0.575795946880815, -0.27805701621112,
-0.857874737912892, -0.104659584246514, 0.17039579591881, -0.865091117878824,
-0.46816744397277, 0.192565655240371, -1.03109447237718, 1.06553877886564,
1.23866934527193, -0.557535778501767, 0.328278137860868, 0.479315913643039,
-0.300320488930954, 0.0933151970105355, 0.45435832685008, 0.353701375296797,
0.0383099326756493, 0.0190470344129186, -0.635917044801381, 0.0283016190441402,
-0.646068533472886, -0.670016902322062, -0.817829408466497, 0.155827427395713,
0.0841895569080921, 0.0789447980825686, 0.0948472432148013, 0.0831841629801644,
0.0962788619480724, 0.0939708773617142, 0.112273655103789, 0.088020923899392,
0.105447335788379, 0.105447335788379, 0.0986210164729702, 0.116445663604253,
0.0939708773617142, 0.0939708773617142, 0.091662892775356, 0.106168562989308,
-0.697735814067351, 0.103116016932067, -0.0119873567567462, 0.0960430676308025,
0.941432617650979, 0.288123076157485, 0.355649205652174, -0.899324319787941,
-0.471374467992702, 1.04089855565463, 0.530167190644324, -0.881219296130415,
0.817295999365089, 0.710965196854967, 0.570414807595831, -0.482451921492823,
-0.897769159938312, -1.13131478961596, 0.0713179062193921, 1.1903661371844,
-0.929926024648498, -0.45579431535985, 0.565319612094792, -0.953436307510131,
-0.326723454579114, 0.897018374284126, -0.678055168692227, -0.985820439935874,
-1.02844848543643, 0.137571705583959, 0.874512274155955, -0.793867741869978,
1.02355534703946, 0.399708078403241, 0.78553936339543, 0.948374652200805,
-0.84500171606876, 1.0107651029816, -0.847100320821151, 0.878483763551771,
0.0241041227612538, -1.0242017546084, -0.322111274771489, 0.0497211100234066,
0.034463087503727, 1.08400921708616, -1.06281639025659, 2.65102961205458,
0.928493782493917, 0.574355910751298, 0.178304303613777, -3.92568791677703,
-0.0859381662546061, -1.05383461865872, -0.784670171088824, 0.612879932055508,
0.614824853316853, 0.680932413915022, -0.356128838631002, 0.967880613279386,
-0.403418243065866, -0.0157469230501156, 1.34230297545746, 0.569288255022056,
-0.375688637519549, -0.359826963953155, 0.339587529470154, -0.900974731798957,
-0.857115762548756, 0.375504782770305, -0.797121138425037, 0.503768691843467,
-0.866431161892649, 0.663600549675666, -0.722554832918408, -0.289734073608805,
-0.965995294901752, -1.05120439891187, 0.674450362237513, 0.942841818923997,
0.960748850981328, 1.05288404644959, -0.91223644566643, -1.03094646360683,
-1.01140328043877, -0.629964689492797, 0.483206205529612, -0.353584472643645,
-0.22330113727128, -0.338004631917077, 0.00580937705700466,
-0.0512036965494825,
-0.546098200382363, -0.645994014084112, 0.396057693143599, -0.305517979804091,
-0.43884131444258, 0.537792971993706, 0.631698997549714, -0.818108347416756,
0.494036772700565, 0.302877778917934, 0.0198185506268238, 0.27517376755051,
2.09789420596354, -0.386803209709186, -0.572844664881136, 0.633540665762449,
1.53772604493417, 0.634428878479271, -0.115218612466389, 0.322586962413804,
-0.145109809456869, -1.04040595235717, -0.131234561676442, -0.548583125399696,
-0.390200804014159, 1.03339303770344, 0.70103070189555, 0.21135711660996,
-0.14597649677606, 0.520204203145368, 1.03542072939764, -0.655737548696032,
0.335067765481652, 0.826426337197544, 1.46273942208774, -0.0503132416153066,
1.7599013466248, 1.21839053486024, 0.108988023318627, -0.121911523699774,
1.1351136101429, 0.399941339425185, -0.228386616128546, -1.27820519197438,
-0.393201592934768, -0.41563092294455, -0.266177152022941, 0.461429762283106,
0.265502318279524, -0.825497126816178, 0.998545563055122, 0.569510823580095,
-0.348754186080459, -0.946014481690295, 0.83301351576945, -0.218984639465139,
0.695418283854028, -1.42766879023276, -0.783519748263237, -0.0185859748462364,
0.22622216659092, -0.842940844293499, -0.84702007245733, -0.501043325178865,
-0.337100300084355, -0.527276704350915, -0.241596182902352, -0.232297524482414,
-1.06831621475657, 1.23820545388447, -1.83595843459505, 0.183901314338659,
0.334823183565408, -0.460994607223178, -0.502081199796652, 0.920071798062979,
0.309151266362348, 1.31086223310642, -0.323557125306088, -1.46317447619701,
-0.935450804091841, 0.714508467300742, -0.96775293828597, 1.05657218141627,
0.498491414060863, 0.515375045885487, 1.11717617916938, -1.61335401057394,
0.908424849763754, 0.623822012960201, -0.477652390668867, -0.632833195851549,
-0.795472695163017, 0.288678717381959, 0.0134839965502857, -1.07029805944507,
-0.746576451586246, 0.375377433515597, -0.297720446602926, -0.320626586750474,
-0.671016587037567, -0.303369965480123, 0.893524856257103, -0.372767113377851,
-0.0665301447571371, -0.479380239164552, 0.897423065124399, 0.893164144945179,
-0.95913778546186, -0.702254101336489, -0.350441981033975, 0.766045715599953,
0.909395426580465, 0.806793813827552, 0.474927337412093, -0.0383057034947468,
-0.454526719533217, -0.187379201707524, 0.249983084438962, 0.632832546743065,
-0.986399675507447, -0.970631383787144), .Dim = c(504L, 2L), .Dimnames = list(
    NULL, c("sensors.sample", "")))

What I'd like to do is get a spline through all the points. I'm
thinking the spline function is my best approach. But a plot of the
spline and the points shows it does not cross every one perfectly. Do
I need to specify a particular method for this, or am I using the
wrong approach? Thanks in advance! -- H
-- 
Sent from my mobile device
Envoyait de mon portable



More information about the R-help mailing list