Re: [R] code for year month day hr format

2024-06-17 Thread Jibrin Alhassan
Hello Rui,
Thanks for your kind and unrelenting help. The code works actually. I will
see what to do to sort things out. Please, accept my indebtedness.
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Mon, Jun 17, 2024 at 8:53 PM Rui Barradas  wrote:

> Às 09:44 de 17/06/2024, Jibrin Alhassan escreveu:
> > Hello Rui,
> > The df1 output printed from June instead of January .Here is part of it.
> > 4288  2012-06-27 15  6.2  420  70   -7 109.9
> > 4289  2012-06-27 16  6.5  442  70   -9 109.9
> > 4290  2012-06-27 17  6.3  450  70   -6 109.9
> > 4291  2012-06-27 18  6.0  453  700 109.9
> > 4292  2012-06-27 19  6.7  473  702 109.9
> > 4293  2012-06-27 20  5.7  460  702 109.9
> > 4294  2012-06-27 21  5.4  469  700 109.9
> > 4295  2012-06-27 22  4.5  485  70   -2 109.9
> > 4296  2012-06-27 23  4.9  497  701 109.9
> > 4297  2012-06-28  0  4.6  500  873 123.7
> > 4298  2012-06-28  1  4.7  503  872 123.7
> > 4299  2012-06-28  2  4.3  488  871 123.7
> > 4300  2012-06-28  3  4.9  479  870 123.7
> > 4301  2012-06-28  4  5.1  459  870 123.7
> > 4302  2012-06-28  5  4.9  458  870 123.7
> > 4303  2012-06-28  6  5.1  460  870 123.7
> > 4304  2012-06-28  7  5.0  451  87   -3 123.7
> > 4305  2012-06-28  8  5.2  452  87   -5 123.7
> > 4306  2012-06-28  9  5.2  445  87   -6 123.7
> > 4307  2012-06-28 10  5.0  430  87   -7 123.7
> > 4308  2012-06-28 11  4.6  434  87   -8 123.7
> > 4309  2012-06-28 12  4.1  442  87   -7 123.7
> > 4310  2012-06-28 13  3.9  433  87   -7 123.7
> > 4311  2012-06-28 14  3.5  421  87   -9 123.7
> > 4312  2012-06-28 15  4.4  420  87   -8 123.7
> > 4313  2012-06-28 16  4.6  421  87   -9 123.7
> > 4314  2012-06-28 17  3.2  417  87   -7 123.7
> > 4315  2012-06-28 18  3.5  415  87   -3 123.7
> > 4316  2012-06-28 19  3.9  394  87   -2 123.7
> > 4317  2012-06-28 20  4.2  407  870 123.7
> > 4318  2012-06-28 21  3.9  411  87   -3 123.7
> > 4319  2012-06-28 22  3.6  420  87   -5 123.7
> > 4320  2012-06-28 23  4.0  423  870 123.7
> > 4321  2012-06-29  0  3.2  418 1035 121.3
> > 4322  2012-06-29  1  3.3  421 1037 121.3
> > 4323  2012-06-29  2  3.7  411 1039 121.3
> > 4324  2012-06-29  3  3.8  413 1039 121.3
> > 4325  2012-06-29  4  3.3  413 1036 121.3
> > 4326  2012-06-29  5  3.2  417 1032 121.3
> > 4327  2012-06-29  6  3.4  414 1032 121.3
> > 4328  2012-06-29  7  3.7  405 1031 121.3
> > 4329  2012-06-29  8  3.9  393 1031 121.3
> > 4330  2012-06-29  9  4.2  385 1032 121.3
> > 4331  2012-06-29 10  4.4  381 1032 121.3
> > 4332  2012-06-29 11  4.0  386 1033 121.3
> > 4333  2012-06-29 12  4.7  386 1035 121.3
> > 4334  2012-06-29 13  5.2  378 1037 121.3
> > 4335  2012-06-29 14  5.1  376 1035 121.3
> > 4336  2012-06-29 15  4.7  366 1032 121.3
> > 4337  2012-06-29 16  4.5  378 1030 121.3
> > 4338  2012-06-29 17  4.8  369 1030 121.3
> > 4339  2012-06-29 18  5.4  365 1030 121.3
> > 4340  2012-06-29 19  5.7  369 1031 121.3
> > 4341  2012-06-29 20  5.8  373 1033 121.3
> > 4342  2012-06-29 21  4.9  392 103   10 121.3
> > 4343  2012-06-29 22  4.0  406 103   19 121.3
> > 4344  2012-06-29 23  7.1  402 103   19 121.3
> > 4345  2012-06-30  0  6.5  398 104   18 128.2
> > 4346  2012-06-30  1  7.6  397 104   12 128.2
> > 4347  2012-06-30  2  8.8  407 104   10 128.2
> > 4348  2012-06-30  3 11.2  404 104   -1 128.2
> > 4349  2012-06-30  4 11.2  410 1041 128.2
> > 4350  2012-06-30  5  8.8  410 1041 128.2
> > 4351  2012-06-30  6  9.7  417 104   -6 128.2
> > 4352  2012-06-30  7 12.3  446 104  -14 128.2
> > 4353  2012-06-30  8  9.5  476 104  -10 128.2
> > 4354  2012-06-30  9  8.7  496 104  -13 128.2
> > 4355  2012-06-30 10 12.6  560 104  -17 128.2
> > 4356  2012-06-30 11 11.4  600 104  -13 128.2
> > 4357  2012-06-30 12 11.4  607 104  -12 128.2
> > 4358  2012-06-30 13 11.1  603 104   -8 128.2
> > 4359  2012-06-30 14 11.1  616 104  -14 128.2
> > 4360  2012-06-30 15  9.7  616 104  -13 128.2
> > 4361  2012-06-30 16  9.7  629 104  -15 128.2
> > 4362  2012-06-30 17  6.6  654 104  -24 128.2
> > 4363  2012-06-30 18  6.5  660 104  -24 128.2
> > 4364  2012-06-30 19  6.8  676 104  -31 128.2
> > 4365  2012-06-30 20  7.2  675 104  -37 128.2
> > 4366  2012-06-30 21  7.0  657 104  -32 128.2
> > 4367  2012-06-30 22  6.4  634 104  -31 128.2
> > 4368  2012-06-30 23  7.6  640 104  -29 128.2
> > 4369  2012-07-01  0  6.9  650 126  -23 137.9
> > 4370  2012-07-01  1  7.0  635 126  -18 137.9
> > 4371  2012-07-01  2  6.9  651 126  -17 137.9
> > 4372  2012-07-01  3  6.3  661 126  -25 137.9
> > 4373  2012-07-01  4  5.6  663 126  -26 137.9
> > 4374  2012-07-01  5  5.4  655 126  -26 137.9
> > 4375  2012-07-01  6  5.1  656 126  -33 137.9
> > 4376  2012-07-01  7  4.9  658 126  -30 137.9
> > 4377  2012-07-01  8  5.1  648 126  -24 137.9
> > 4378  2012-07-01  9  5.0  643 126  -24 137.9
> > 4379  2012-07-01 10  5.0  633 126  -20 137.9
> > 4380  2012-07-01 11  5.1  650 126  

Re: [R] code for year month day hr format

2024-06-17 Thread Rui Barradas

Às 09:44 de 17/06/2024, Jibrin Alhassan escreveu:

Hello Rui,
The df1 output printed from June instead of January .Here is part of it.
4288  2012-06-27 15  6.2  420  70   -7 109.9
4289  2012-06-27 16  6.5  442  70   -9 109.9
4290  2012-06-27 17  6.3  450  70   -6 109.9
4291  2012-06-27 18  6.0  453  700 109.9
4292  2012-06-27 19  6.7  473  702 109.9
4293  2012-06-27 20  5.7  460  702 109.9
4294  2012-06-27 21  5.4  469  700 109.9
4295  2012-06-27 22  4.5  485  70   -2 109.9
4296  2012-06-27 23  4.9  497  701 109.9
4297  2012-06-28  0  4.6  500  873 123.7
4298  2012-06-28  1  4.7  503  872 123.7
4299  2012-06-28  2  4.3  488  871 123.7
4300  2012-06-28  3  4.9  479  870 123.7
4301  2012-06-28  4  5.1  459  870 123.7
4302  2012-06-28  5  4.9  458  870 123.7
4303  2012-06-28  6  5.1  460  870 123.7
4304  2012-06-28  7  5.0  451  87   -3 123.7
4305  2012-06-28  8  5.2  452  87   -5 123.7
4306  2012-06-28  9  5.2  445  87   -6 123.7
4307  2012-06-28 10  5.0  430  87   -7 123.7
4308  2012-06-28 11  4.6  434  87   -8 123.7
4309  2012-06-28 12  4.1  442  87   -7 123.7
4310  2012-06-28 13  3.9  433  87   -7 123.7
4311  2012-06-28 14  3.5  421  87   -9 123.7
4312  2012-06-28 15  4.4  420  87   -8 123.7
4313  2012-06-28 16  4.6  421  87   -9 123.7
4314  2012-06-28 17  3.2  417  87   -7 123.7
4315  2012-06-28 18  3.5  415  87   -3 123.7
4316  2012-06-28 19  3.9  394  87   -2 123.7
4317  2012-06-28 20  4.2  407  870 123.7
4318  2012-06-28 21  3.9  411  87   -3 123.7
4319  2012-06-28 22  3.6  420  87   -5 123.7
4320  2012-06-28 23  4.0  423  870 123.7
4321  2012-06-29  0  3.2  418 1035 121.3
4322  2012-06-29  1  3.3  421 1037 121.3
4323  2012-06-29  2  3.7  411 1039 121.3
4324  2012-06-29  3  3.8  413 1039 121.3
4325  2012-06-29  4  3.3  413 1036 121.3
4326  2012-06-29  5  3.2  417 1032 121.3
4327  2012-06-29  6  3.4  414 1032 121.3
4328  2012-06-29  7  3.7  405 1031 121.3
4329  2012-06-29  8  3.9  393 1031 121.3
4330  2012-06-29  9  4.2  385 1032 121.3
4331  2012-06-29 10  4.4  381 1032 121.3
4332  2012-06-29 11  4.0  386 1033 121.3
4333  2012-06-29 12  4.7  386 1035 121.3
4334  2012-06-29 13  5.2  378 1037 121.3
4335  2012-06-29 14  5.1  376 1035 121.3
4336  2012-06-29 15  4.7  366 1032 121.3
4337  2012-06-29 16  4.5  378 1030 121.3
4338  2012-06-29 17  4.8  369 1030 121.3
4339  2012-06-29 18  5.4  365 1030 121.3
4340  2012-06-29 19  5.7  369 1031 121.3
4341  2012-06-29 20  5.8  373 1033 121.3
4342  2012-06-29 21  4.9  392 103   10 121.3
4343  2012-06-29 22  4.0  406 103   19 121.3
4344  2012-06-29 23  7.1  402 103   19 121.3
4345  2012-06-30  0  6.5  398 104   18 128.2
4346  2012-06-30  1  7.6  397 104   12 128.2
4347  2012-06-30  2  8.8  407 104   10 128.2
4348  2012-06-30  3 11.2  404 104   -1 128.2
4349  2012-06-30  4 11.2  410 1041 128.2
4350  2012-06-30  5  8.8  410 1041 128.2
4351  2012-06-30  6  9.7  417 104   -6 128.2
4352  2012-06-30  7 12.3  446 104  -14 128.2
4353  2012-06-30  8  9.5  476 104  -10 128.2
4354  2012-06-30  9  8.7  496 104  -13 128.2
4355  2012-06-30 10 12.6  560 104  -17 128.2
4356  2012-06-30 11 11.4  600 104  -13 128.2
4357  2012-06-30 12 11.4  607 104  -12 128.2
4358  2012-06-30 13 11.1  603 104   -8 128.2
4359  2012-06-30 14 11.1  616 104  -14 128.2
4360  2012-06-30 15  9.7  616 104  -13 128.2
4361  2012-06-30 16  9.7  629 104  -15 128.2
4362  2012-06-30 17  6.6  654 104  -24 128.2
4363  2012-06-30 18  6.5  660 104  -24 128.2
4364  2012-06-30 19  6.8  676 104  -31 128.2
4365  2012-06-30 20  7.2  675 104  -37 128.2
4366  2012-06-30 21  7.0  657 104  -32 128.2
4367  2012-06-30 22  6.4  634 104  -31 128.2
4368  2012-06-30 23  7.6  640 104  -29 128.2
4369  2012-07-01  0  6.9  650 126  -23 137.9
4370  2012-07-01  1  7.0  635 126  -18 137.9
4371  2012-07-01  2  6.9  651 126  -17 137.9
4372  2012-07-01  3  6.3  661 126  -25 137.9
4373  2012-07-01  4  5.6  663 126  -26 137.9
4374  2012-07-01  5  5.4  655 126  -26 137.9
4375  2012-07-01  6  5.1  656 126  -33 137.9
4376  2012-07-01  7  4.9  658 126  -30 137.9
4377  2012-07-01  8  5.1  648 126  -24 137.9
4378  2012-07-01  9  5.0  643 126  -24 137.9
4379  2012-07-01 10  5.0  633 126  -20 137.9
4380  2012-07-01 11  5.1  650 126  -17 137.9
4381  2012-07-01 12  5.2  687 126  -13 137.9
4382  2012-07-01 13  5.0  653 126   -8 137.9
4383  2012-07-01 14  4.9  648 126  -12 137.9
4384  2012-07-01 15  5.7  661 126  -11 137.9
4385  2012-07-01 16  5.7  665 126  -10 137.9
4386  2012-07-01 17  5.9  655 126  -12 137.9
4387  2012-07-01 18  5.1  647 126  -10 137.9
4388  2012-07-01 19  4.9  638 126  -16 137.9
4389  2012-07-01 20  5.1  633 126  -17 137.9
4390  2012-07-01 21  5.8  642 126  -16 137.9
4391  2012-07-01 22  5.8  635 126  -18 137.9
4392  2012-07-01 23  5.6  639 126  -16 137.9
4393  2012-07-02  0  5.2  653 128  -15 171.4
4394  2012-07-02  1  6.0  642 128  -12 171.4
4395  2012-07-02  2  5.3  664 128  -16 171.4
439

Re: [R] code for year month day hr format

2024-06-17 Thread Jibrin Alhassan
Hello Rui,
The df1 output printed from June instead of January .Here is part of it.
4288  2012-06-27 15  6.2  420  70   -7 109.9
4289  2012-06-27 16  6.5  442  70   -9 109.9
4290  2012-06-27 17  6.3  450  70   -6 109.9
4291  2012-06-27 18  6.0  453  700 109.9
4292  2012-06-27 19  6.7  473  702 109.9
4293  2012-06-27 20  5.7  460  702 109.9
4294  2012-06-27 21  5.4  469  700 109.9
4295  2012-06-27 22  4.5  485  70   -2 109.9
4296  2012-06-27 23  4.9  497  701 109.9
4297  2012-06-28  0  4.6  500  873 123.7
4298  2012-06-28  1  4.7  503  872 123.7
4299  2012-06-28  2  4.3  488  871 123.7
4300  2012-06-28  3  4.9  479  870 123.7
4301  2012-06-28  4  5.1  459  870 123.7
4302  2012-06-28  5  4.9  458  870 123.7
4303  2012-06-28  6  5.1  460  870 123.7
4304  2012-06-28  7  5.0  451  87   -3 123.7
4305  2012-06-28  8  5.2  452  87   -5 123.7
4306  2012-06-28  9  5.2  445  87   -6 123.7
4307  2012-06-28 10  5.0  430  87   -7 123.7
4308  2012-06-28 11  4.6  434  87   -8 123.7
4309  2012-06-28 12  4.1  442  87   -7 123.7
4310  2012-06-28 13  3.9  433  87   -7 123.7
4311  2012-06-28 14  3.5  421  87   -9 123.7
4312  2012-06-28 15  4.4  420  87   -8 123.7
4313  2012-06-28 16  4.6  421  87   -9 123.7
4314  2012-06-28 17  3.2  417  87   -7 123.7
4315  2012-06-28 18  3.5  415  87   -3 123.7
4316  2012-06-28 19  3.9  394  87   -2 123.7
4317  2012-06-28 20  4.2  407  870 123.7
4318  2012-06-28 21  3.9  411  87   -3 123.7
4319  2012-06-28 22  3.6  420  87   -5 123.7
4320  2012-06-28 23  4.0  423  870 123.7
4321  2012-06-29  0  3.2  418 1035 121.3
4322  2012-06-29  1  3.3  421 1037 121.3
4323  2012-06-29  2  3.7  411 1039 121.3
4324  2012-06-29  3  3.8  413 1039 121.3
4325  2012-06-29  4  3.3  413 1036 121.3
4326  2012-06-29  5  3.2  417 1032 121.3
4327  2012-06-29  6  3.4  414 1032 121.3
4328  2012-06-29  7  3.7  405 1031 121.3
4329  2012-06-29  8  3.9  393 1031 121.3
4330  2012-06-29  9  4.2  385 1032 121.3
4331  2012-06-29 10  4.4  381 1032 121.3
4332  2012-06-29 11  4.0  386 1033 121.3
4333  2012-06-29 12  4.7  386 1035 121.3
4334  2012-06-29 13  5.2  378 1037 121.3
4335  2012-06-29 14  5.1  376 1035 121.3
4336  2012-06-29 15  4.7  366 1032 121.3
4337  2012-06-29 16  4.5  378 1030 121.3
4338  2012-06-29 17  4.8  369 1030 121.3
4339  2012-06-29 18  5.4  365 1030 121.3
4340  2012-06-29 19  5.7  369 1031 121.3
4341  2012-06-29 20  5.8  373 1033 121.3
4342  2012-06-29 21  4.9  392 103   10 121.3
4343  2012-06-29 22  4.0  406 103   19 121.3
4344  2012-06-29 23  7.1  402 103   19 121.3
4345  2012-06-30  0  6.5  398 104   18 128.2
4346  2012-06-30  1  7.6  397 104   12 128.2
4347  2012-06-30  2  8.8  407 104   10 128.2
4348  2012-06-30  3 11.2  404 104   -1 128.2
4349  2012-06-30  4 11.2  410 1041 128.2
4350  2012-06-30  5  8.8  410 1041 128.2
4351  2012-06-30  6  9.7  417 104   -6 128.2
4352  2012-06-30  7 12.3  446 104  -14 128.2
4353  2012-06-30  8  9.5  476 104  -10 128.2
4354  2012-06-30  9  8.7  496 104  -13 128.2
4355  2012-06-30 10 12.6  560 104  -17 128.2
4356  2012-06-30 11 11.4  600 104  -13 128.2
4357  2012-06-30 12 11.4  607 104  -12 128.2
4358  2012-06-30 13 11.1  603 104   -8 128.2
4359  2012-06-30 14 11.1  616 104  -14 128.2
4360  2012-06-30 15  9.7  616 104  -13 128.2
4361  2012-06-30 16  9.7  629 104  -15 128.2
4362  2012-06-30 17  6.6  654 104  -24 128.2
4363  2012-06-30 18  6.5  660 104  -24 128.2
4364  2012-06-30 19  6.8  676 104  -31 128.2
4365  2012-06-30 20  7.2  675 104  -37 128.2
4366  2012-06-30 21  7.0  657 104  -32 128.2
4367  2012-06-30 22  6.4  634 104  -31 128.2
4368  2012-06-30 23  7.6  640 104  -29 128.2
4369  2012-07-01  0  6.9  650 126  -23 137.9
4370  2012-07-01  1  7.0  635 126  -18 137.9
4371  2012-07-01  2  6.9  651 126  -17 137.9
4372  2012-07-01  3  6.3  661 126  -25 137.9
4373  2012-07-01  4  5.6  663 126  -26 137.9
4374  2012-07-01  5  5.4  655 126  -26 137.9
4375  2012-07-01  6  5.1  656 126  -33 137.9
4376  2012-07-01  7  4.9  658 126  -30 137.9
4377  2012-07-01  8  5.1  648 126  -24 137.9
4378  2012-07-01  9  5.0  643 126  -24 137.9
4379  2012-07-01 10  5.0  633 126  -20 137.9
4380  2012-07-01 11  5.1  650 126  -17 137.9
4381  2012-07-01 12  5.2  687 126  -13 137.9
4382  2012-07-01 13  5.0  653 126   -8 137.9
4383  2012-07-01 14  4.9  648 126  -12 137.9
4384  2012-07-01 15  5.7  661 126  -11 137.9
4385  2012-07-01 16  5.7  665 126  -10 137.9
4386  2012-07-01 17  5.9  655 126  -12 137.9
4387  2012-07-01 18  5.1  647 126  -10 137.9
4388  2012-07-01 19  4.9  638 126  -16 137.9
4389  2012-07-01 20  5.1  633 126  -17 137.9
4390  2012-07-01 21  5.8  642 126  -16 137.9
4391  2012-07-01 22  5.8  635 126  -18 137.9
4392  2012-07-01 23  5.6  639 126  -16 137.9
4393  2012-07-02  0  5.2  653 128  -15 171.4
4394  2012-07-02  1  6.0  642 128  -12 171.4
4395  2012-07-02  2  5.3  664 128  -16 171.4
4396  2012-07-02  3  5.2  676 128  -13 171.4
4397  2012

Re: [R] code for year month day hr format

2024-06-17 Thread Rui Barradas

Às 09:12 de 17/06/2024, Jibrin Alhassan escreveu:

Hello Rui,
Here is the head(df1) output
Date HR IMF SWS SSN Dst f10.7
1 2012-01-01  0 4.0 379  71  -8 999.9
2 2012-01-01  1 4.4 386  71  -3 999.9
3 2012-01-01  2 4.8 380  71  -4 999.9
4 2012-01-01  3 5.4 374  71  -5 999.9
5 2012-01-01  4 4.5 369  71  -9 999.9
6 2012-01-01  5 4.2 368  71  -7 999.9
Many thanks.
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Mon, Jun 17, 2024 at 8:14 AM Rui Barradas  wrote:


Às 07:53 de 17/06/2024, Jibrin Alhassan escreveu:

Part of it is pasted below
YEAR DOY HRIMF SWS   SSN   Dst f10.7
2012   1  0   4.0  379.  71-8 999.9
2012   1  1   4.4  386.  71-3 999.9
2012   1  2   4.8  380.  71-4 999.9
2012   1  3   5.4  374.  71-5 999.9
2012   1  4   4.5  369.  71-9 999.9
2012   1  5   4.2  368.  71-7 999.9
2012   1  6   4.7  367.  71-6 999.9
2012   1  7   4.1  361.  71   -10 999.9
2012   1  8   3.2  362.  71-7 999.9
2012   1  9   4.3  367.  71-3 999.9
2012   1 10   4.5  365.  71-6 999.9
2012   1 11   5.6  369.  71-8 999.9
2012   1 12   5.2  366.  71-8 999.9
2012   1 13   4.4  370.  71-7 999.9
2012   1 14   4.8  357.  71-5 999.9
2012   1 15   4.6  354.  71-8 999.9
2012   1 16   3.7  382.  71-7 999.9
2012   1 17   3.2  376.  71-2 999.9
2012   1 18   2.8  368.  71 2 999.9
2012   1 19   3.2  361.  71 2 999.9
2012   1 20   3.2  361.  71-3 999.9
2012   1 21   3.5  365.  71-5 999.9
2012   1 22   3.6  364.  71-3 999.9
2012   1 23   3.0  362.  71-3 999.9
2012   2  0   3.2  359.  92-5 130.3
2012   2  1   3.0  361.  92-4 130.3
2012   2  2   4.5  374.  92 3 130.3
2012   2  3   4.5  364.  92 5 130.3
2012   2  4   5.1  352.  92 3 130.3
2012   2  5   4.9  358.  92 3 130.3
2012   2  6   4.4  346.  92 4 130.3
2012   2  7   4.2  349.  92 7 130.3
2012   2  8   4.5  346.  92 8 130.3
2012   2  9   5.2  345.  92 7 130.3
2012   2 10   5.0  349.  92 5 130.3
2012   2 11   4.8  345.  92 0 130.3
2012   2 12   5.3  347.  92 0 130.3
2012   2 13   5.5  342.  92 0 130.3
2012   2 14   6.1  359.  92 1 130.3
2012   2 15   6.2  393.  92 8 130.3
2012   2 16   6.7  390.  9210 130.3
2012   2 17   7.7  369.  9210 130.3
2012   2 18   9.4  380.  9214 130.3
2012   2 19  10.6  386.  9212 130.3
2012   2 20  10.2  378.  9211 130.3
2012   2 21  11.6  369.  92 7 130.3
2012   2 22  12.0  369.  92 8 130.3
2012   2 23  10.5  361.  92 1 130.3
2012   3  0  11.3  403. 120-7 130.2
2012   3  1  10.3  412. 120   -14 130.2
2012   3  2   8.8  419. 120   -18 130.2
2012   3  3   8.3  412. 120   -23 130.2
2012   3  4   8.0  408. 120   -25 130.2
2012   3  5   7.0  380. 120   -28 130.2
2012   3  6   6.9  374. 120   -29 130.2
2012   3  7   6.9  372. 120   -30 130.2
2012   3  8   7.1  365. 120   -32 130.2
2012   3  9   6.8  376. 120   -35 130.2
2012   3 10   6.7  380. 120   -35 130.2
2012   3 11   6.4  381. 120   -30 130.2
2012   3 12   5.9  401. 120   -26 130.2
2012   3 13   5.9  405. 120   -23 130.2
2012   3 14   5.9  413. 120   -20 130.2
2012   3 15   5.9  406. 120   -20 130.2
2012   3 16   6.3  427. 120   -20 130.2
2012   3 17   5.9  424. 120   -19 130.2
2012   3 18   4.8  390. 120   -16 130.2
2012   3 19   4.8  374. 120   -15 130.2
2012   3 20   4.8  374. 120   -15 130.2
2012   3 21   5.1  378. 120   -18 130.2
2012   3 22   4.9  375. 120   -19 130.2
2012   3 23   4.7  364. 120   -17 130.2
2012   4  0   4.3  359. 126   -17 131.6
2012   4  1   4.3  359. 126   -15 131.6
2012   4  2   4.2  358. 126   -13 131.6
2012   4  3   3.8  359. 126   -13 131.6
2012   4  4   3.8  358. 126   -13 131.6
2012   4  5   3.7  359. 126   -14 131.6
2012   4  6   3.9  361. 126   -13 131.6
2012   4  7   3.7  364. 126   -13 131.6
2012   4  8   3.7  366. 126   -12 131.6
2012   4  9   3.8  363. 126   -10 131.6
2012   4 10   3.5  363. 126-8 131.6
2012   4 11   3.0  352. 126   -10 131.6
2012   4 12   3.1  348. 126   -12 131.6
2012   4 13   3.3  340. 126-9 131.6
2012   4 14   4.0  343. 126-8 131.6
2012   4 15   4.2  343. 126-7 131.6
2012   4 16   3.8  336. 126-5 131.6
2012   4 17   3.9  334. 126-6 131.6
2012   4 18   3.8  329. 126-5 131.6
2012   4 19   3.8  326. 126-4 131.6
2012   4 20   4.3  337. 126-3 131.6
2012   4 21   3.9  331. 126 0 131.6
2012   4 22   3.8  322. 126-1 131.6
2012   4 23   3.5  331. 126-1 131.6
2012   5  0   3.9  312. 109-3 136.6
2012   5  1   3.6  311. 109-1 136.6
2012   5  2   3.7  312. 109 0 136.6
2012   5  3   3.8  308. 109 0 136.6
2012   5  4   4.0  305. 109 2 136.6
2012   5  5   4.5  309. 109 2 136.6
2012   5  6   3.5  314. 109 3 136.6
2012   5  7   3.6  305. 109 2 136.6
2012   5  8   4.3  307. 109 2 136.6
2012   5  9   4.6  316. 109 1 136.6
2012   5 10   5.0  321. 109-4 136.6
2012   5 11   5.1  321. 109-6 136.6
2012   5 12   4.6  326. 109-4 136.6
2

Re: [R] code for year month day hr format

2024-06-17 Thread Jibrin Alhassan
Hello Rui,
Here is the head(df1) output
Date HR IMF SWS SSN Dst f10.7
1 2012-01-01  0 4.0 379  71  -8 999.9
2 2012-01-01  1 4.4 386  71  -3 999.9
3 2012-01-01  2 4.8 380  71  -4 999.9
4 2012-01-01  3 5.4 374  71  -5 999.9
5 2012-01-01  4 4.5 369  71  -9 999.9
6 2012-01-01  5 4.2 368  71  -7 999.9
Many thanks.
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Mon, Jun 17, 2024 at 8:14 AM Rui Barradas  wrote:

> Às 07:53 de 17/06/2024, Jibrin Alhassan escreveu:
> > Part of it is pasted below
> > YEAR DOY HRIMF SWS   SSN   Dst f10.7
> > 2012   1  0   4.0  379.  71-8 999.9
> > 2012   1  1   4.4  386.  71-3 999.9
> > 2012   1  2   4.8  380.  71-4 999.9
> > 2012   1  3   5.4  374.  71-5 999.9
> > 2012   1  4   4.5  369.  71-9 999.9
> > 2012   1  5   4.2  368.  71-7 999.9
> > 2012   1  6   4.7  367.  71-6 999.9
> > 2012   1  7   4.1  361.  71   -10 999.9
> > 2012   1  8   3.2  362.  71-7 999.9
> > 2012   1  9   4.3  367.  71-3 999.9
> > 2012   1 10   4.5  365.  71-6 999.9
> > 2012   1 11   5.6  369.  71-8 999.9
> > 2012   1 12   5.2  366.  71-8 999.9
> > 2012   1 13   4.4  370.  71-7 999.9
> > 2012   1 14   4.8  357.  71-5 999.9
> > 2012   1 15   4.6  354.  71-8 999.9
> > 2012   1 16   3.7  382.  71-7 999.9
> > 2012   1 17   3.2  376.  71-2 999.9
> > 2012   1 18   2.8  368.  71 2 999.9
> > 2012   1 19   3.2  361.  71 2 999.9
> > 2012   1 20   3.2  361.  71-3 999.9
> > 2012   1 21   3.5  365.  71-5 999.9
> > 2012   1 22   3.6  364.  71-3 999.9
> > 2012   1 23   3.0  362.  71-3 999.9
> > 2012   2  0   3.2  359.  92-5 130.3
> > 2012   2  1   3.0  361.  92-4 130.3
> > 2012   2  2   4.5  374.  92 3 130.3
> > 2012   2  3   4.5  364.  92 5 130.3
> > 2012   2  4   5.1  352.  92 3 130.3
> > 2012   2  5   4.9  358.  92 3 130.3
> > 2012   2  6   4.4  346.  92 4 130.3
> > 2012   2  7   4.2  349.  92 7 130.3
> > 2012   2  8   4.5  346.  92 8 130.3
> > 2012   2  9   5.2  345.  92 7 130.3
> > 2012   2 10   5.0  349.  92 5 130.3
> > 2012   2 11   4.8  345.  92 0 130.3
> > 2012   2 12   5.3  347.  92 0 130.3
> > 2012   2 13   5.5  342.  92 0 130.3
> > 2012   2 14   6.1  359.  92 1 130.3
> > 2012   2 15   6.2  393.  92 8 130.3
> > 2012   2 16   6.7  390.  9210 130.3
> > 2012   2 17   7.7  369.  9210 130.3
> > 2012   2 18   9.4  380.  9214 130.3
> > 2012   2 19  10.6  386.  9212 130.3
> > 2012   2 20  10.2  378.  9211 130.3
> > 2012   2 21  11.6  369.  92 7 130.3
> > 2012   2 22  12.0  369.  92 8 130.3
> > 2012   2 23  10.5  361.  92 1 130.3
> > 2012   3  0  11.3  403. 120-7 130.2
> > 2012   3  1  10.3  412. 120   -14 130.2
> > 2012   3  2   8.8  419. 120   -18 130.2
> > 2012   3  3   8.3  412. 120   -23 130.2
> > 2012   3  4   8.0  408. 120   -25 130.2
> > 2012   3  5   7.0  380. 120   -28 130.2
> > 2012   3  6   6.9  374. 120   -29 130.2
> > 2012   3  7   6.9  372. 120   -30 130.2
> > 2012   3  8   7.1  365. 120   -32 130.2
> > 2012   3  9   6.8  376. 120   -35 130.2
> > 2012   3 10   6.7  380. 120   -35 130.2
> > 2012   3 11   6.4  381. 120   -30 130.2
> > 2012   3 12   5.9  401. 120   -26 130.2
> > 2012   3 13   5.9  405. 120   -23 130.2
> > 2012   3 14   5.9  413. 120   -20 130.2
> > 2012   3 15   5.9  406. 120   -20 130.2
> > 2012   3 16   6.3  427. 120   -20 130.2
> > 2012   3 17   5.9  424. 120   -19 130.2
> > 2012   3 18   4.8  390. 120   -16 130.2
> > 2012   3 19   4.8  374. 120   -15 130.2
> > 2012   3 20   4.8  374. 120   -15 130.2
> > 2012   3 21   5.1  378. 120   -18 130.2
> > 2012   3 22   4.9  375. 120   -19 130.2
> > 2012   3 23   4.7  364. 120   -17 130.2
> > 2012   4  0   4.3  359. 126   -17 131.6
> > 2012   4  1   4.3  359. 126   -15 131.6
> > 2012   4  2   4.2  358. 126   -13 131.6
> > 2012   4  3   3.8  359. 126   -13 131.6
> > 2012   4  4   3.8  358. 126   -13 131.6
> > 2012   4  5   3.7  359. 126   -14 131.6
> > 2012   4  6   3.9  361. 126   -13 131.6
> > 2012   4  7   3.7  364. 126   -13 131.6
> > 2012   4  8   3.7  366. 126   -12 131.6
> > 2012   4  9   3.8  363. 126   -10 131.6
> > 2012   4 10   3.5  363. 126-8 131.6
> > 2012   4 11   3.0  352. 126   -10 131.6
> > 2012   4 12   3.1  348. 126   -12 131.6
> > 2012   4 13   3.3  340. 126-9 131.6
> > 2012   4 14   4.0  343. 126-8 131.6
> > 2012   4 15   4.2  343. 126-7 131.6
> > 2012   4 16   3.8  336. 126-5 131.6
> > 2012   4 17   3.9  334. 126-6 131.6
> > 2012   4 18   3.8  329. 126-5 131.6
> > 2012   4 19   3.8  326. 126-4 131.6
> > 2012   4 20   4.3  337. 126-3 131.6
> > 2012   4 21   3.9  331. 126 0 131.6
> > 2012   4 22   3.8  322. 126-1 131.6
> > 2012   4 23   3.5  331. 126-1 131.6
> > 2012   5  0   3.9  312. 109-3 136.6
> > 2012   5  1   3.6  311. 109-1 136.6
> > 2012   5  2   3.7  312. 109 0 136.6
> > 2012   5  3   3.8  308. 109 0 136.6
> > 2

Re: [R] code for year month day hr format

2024-06-17 Thread Rui Barradas

Às 07:53 de 17/06/2024, Jibrin Alhassan escreveu:

Part of it is pasted below
YEAR DOY HRIMF SWS   SSN   Dst f10.7
2012   1  0   4.0  379.  71-8 999.9
2012   1  1   4.4  386.  71-3 999.9
2012   1  2   4.8  380.  71-4 999.9
2012   1  3   5.4  374.  71-5 999.9
2012   1  4   4.5  369.  71-9 999.9
2012   1  5   4.2  368.  71-7 999.9
2012   1  6   4.7  367.  71-6 999.9
2012   1  7   4.1  361.  71   -10 999.9
2012   1  8   3.2  362.  71-7 999.9
2012   1  9   4.3  367.  71-3 999.9
2012   1 10   4.5  365.  71-6 999.9
2012   1 11   5.6  369.  71-8 999.9
2012   1 12   5.2  366.  71-8 999.9
2012   1 13   4.4  370.  71-7 999.9
2012   1 14   4.8  357.  71-5 999.9
2012   1 15   4.6  354.  71-8 999.9
2012   1 16   3.7  382.  71-7 999.9
2012   1 17   3.2  376.  71-2 999.9
2012   1 18   2.8  368.  71 2 999.9
2012   1 19   3.2  361.  71 2 999.9
2012   1 20   3.2  361.  71-3 999.9
2012   1 21   3.5  365.  71-5 999.9
2012   1 22   3.6  364.  71-3 999.9
2012   1 23   3.0  362.  71-3 999.9
2012   2  0   3.2  359.  92-5 130.3
2012   2  1   3.0  361.  92-4 130.3
2012   2  2   4.5  374.  92 3 130.3
2012   2  3   4.5  364.  92 5 130.3
2012   2  4   5.1  352.  92 3 130.3
2012   2  5   4.9  358.  92 3 130.3
2012   2  6   4.4  346.  92 4 130.3
2012   2  7   4.2  349.  92 7 130.3
2012   2  8   4.5  346.  92 8 130.3
2012   2  9   5.2  345.  92 7 130.3
2012   2 10   5.0  349.  92 5 130.3
2012   2 11   4.8  345.  92 0 130.3
2012   2 12   5.3  347.  92 0 130.3
2012   2 13   5.5  342.  92 0 130.3
2012   2 14   6.1  359.  92 1 130.3
2012   2 15   6.2  393.  92 8 130.3
2012   2 16   6.7  390.  9210 130.3
2012   2 17   7.7  369.  9210 130.3
2012   2 18   9.4  380.  9214 130.3
2012   2 19  10.6  386.  9212 130.3
2012   2 20  10.2  378.  9211 130.3
2012   2 21  11.6  369.  92 7 130.3
2012   2 22  12.0  369.  92 8 130.3
2012   2 23  10.5  361.  92 1 130.3
2012   3  0  11.3  403. 120-7 130.2
2012   3  1  10.3  412. 120   -14 130.2
2012   3  2   8.8  419. 120   -18 130.2
2012   3  3   8.3  412. 120   -23 130.2
2012   3  4   8.0  408. 120   -25 130.2
2012   3  5   7.0  380. 120   -28 130.2
2012   3  6   6.9  374. 120   -29 130.2
2012   3  7   6.9  372. 120   -30 130.2
2012   3  8   7.1  365. 120   -32 130.2
2012   3  9   6.8  376. 120   -35 130.2
2012   3 10   6.7  380. 120   -35 130.2
2012   3 11   6.4  381. 120   -30 130.2
2012   3 12   5.9  401. 120   -26 130.2
2012   3 13   5.9  405. 120   -23 130.2
2012   3 14   5.9  413. 120   -20 130.2
2012   3 15   5.9  406. 120   -20 130.2
2012   3 16   6.3  427. 120   -20 130.2
2012   3 17   5.9  424. 120   -19 130.2
2012   3 18   4.8  390. 120   -16 130.2
2012   3 19   4.8  374. 120   -15 130.2
2012   3 20   4.8  374. 120   -15 130.2
2012   3 21   5.1  378. 120   -18 130.2
2012   3 22   4.9  375. 120   -19 130.2
2012   3 23   4.7  364. 120   -17 130.2
2012   4  0   4.3  359. 126   -17 131.6
2012   4  1   4.3  359. 126   -15 131.6
2012   4  2   4.2  358. 126   -13 131.6
2012   4  3   3.8  359. 126   -13 131.6
2012   4  4   3.8  358. 126   -13 131.6
2012   4  5   3.7  359. 126   -14 131.6
2012   4  6   3.9  361. 126   -13 131.6
2012   4  7   3.7  364. 126   -13 131.6
2012   4  8   3.7  366. 126   -12 131.6
2012   4  9   3.8  363. 126   -10 131.6
2012   4 10   3.5  363. 126-8 131.6
2012   4 11   3.0  352. 126   -10 131.6
2012   4 12   3.1  348. 126   -12 131.6
2012   4 13   3.3  340. 126-9 131.6
2012   4 14   4.0  343. 126-8 131.6
2012   4 15   4.2  343. 126-7 131.6
2012   4 16   3.8  336. 126-5 131.6
2012   4 17   3.9  334. 126-6 131.6
2012   4 18   3.8  329. 126-5 131.6
2012   4 19   3.8  326. 126-4 131.6
2012   4 20   4.3  337. 126-3 131.6
2012   4 21   3.9  331. 126 0 131.6
2012   4 22   3.8  322. 126-1 131.6
2012   4 23   3.5  331. 126-1 131.6
2012   5  0   3.9  312. 109-3 136.6
2012   5  1   3.6  311. 109-1 136.6
2012   5  2   3.7  312. 109 0 136.6
2012   5  3   3.8  308. 109 0 136.6
2012   5  4   4.0  305. 109 2 136.6
2012   5  5   4.5  309. 109 2 136.6
2012   5  6   3.5  314. 109 3 136.6
2012   5  7   3.6  305. 109 2 136.6
2012   5  8   4.3  307. 109 2 136.6
2012   5  9   4.6  316. 109 1 136.6
2012   5 10   5.0  321. 109-4 136.6
2012   5 11   5.1  321. 109-6 136.6
2012   5 12   4.6  326. 109-4 136.6
2012   5 13   5.7  321. 109-2 136.6
2012   5 14   5.0  316. 109 1 136.6
2012   5 15   4.6  315. 109 2 136.6
2012   5 16   5.5  321. 109 7 136.6
2012   5 17   7.2  327. 109 7 136.6
2012   5 18   9.2  329. 109 3 136.6
2012   5 19   9.4  341. 109 3 136.6
2012   5 20   9.2  345. 109 8 136.6
2012   5 21   9.8  344. 109 9 136.6
2012   5 22   9.8  341. 10910 136.6
2012   5 23  10.0  351. 10915 136.6
2012   6  0  10.4  356. 11312 131.0
2012   6  1   9.1  360. 11310 131.0

Re: [R] code for year month day hr format

2024-06-17 Thread Jibrin Alhassan
Part of it is pasted below
YEAR DOY HRIMF SWS   SSN   Dst f10.7
2012   1  0   4.0  379.  71-8 999.9
2012   1  1   4.4  386.  71-3 999.9
2012   1  2   4.8  380.  71-4 999.9
2012   1  3   5.4  374.  71-5 999.9
2012   1  4   4.5  369.  71-9 999.9
2012   1  5   4.2  368.  71-7 999.9
2012   1  6   4.7  367.  71-6 999.9
2012   1  7   4.1  361.  71   -10 999.9
2012   1  8   3.2  362.  71-7 999.9
2012   1  9   4.3  367.  71-3 999.9
2012   1 10   4.5  365.  71-6 999.9
2012   1 11   5.6  369.  71-8 999.9
2012   1 12   5.2  366.  71-8 999.9
2012   1 13   4.4  370.  71-7 999.9
2012   1 14   4.8  357.  71-5 999.9
2012   1 15   4.6  354.  71-8 999.9
2012   1 16   3.7  382.  71-7 999.9
2012   1 17   3.2  376.  71-2 999.9
2012   1 18   2.8  368.  71 2 999.9
2012   1 19   3.2  361.  71 2 999.9
2012   1 20   3.2  361.  71-3 999.9
2012   1 21   3.5  365.  71-5 999.9
2012   1 22   3.6  364.  71-3 999.9
2012   1 23   3.0  362.  71-3 999.9
2012   2  0   3.2  359.  92-5 130.3
2012   2  1   3.0  361.  92-4 130.3
2012   2  2   4.5  374.  92 3 130.3
2012   2  3   4.5  364.  92 5 130.3
2012   2  4   5.1  352.  92 3 130.3
2012   2  5   4.9  358.  92 3 130.3
2012   2  6   4.4  346.  92 4 130.3
2012   2  7   4.2  349.  92 7 130.3
2012   2  8   4.5  346.  92 8 130.3
2012   2  9   5.2  345.  92 7 130.3
2012   2 10   5.0  349.  92 5 130.3
2012   2 11   4.8  345.  92 0 130.3
2012   2 12   5.3  347.  92 0 130.3
2012   2 13   5.5  342.  92 0 130.3
2012   2 14   6.1  359.  92 1 130.3
2012   2 15   6.2  393.  92 8 130.3
2012   2 16   6.7  390.  9210 130.3
2012   2 17   7.7  369.  9210 130.3
2012   2 18   9.4  380.  9214 130.3
2012   2 19  10.6  386.  9212 130.3
2012   2 20  10.2  378.  9211 130.3
2012   2 21  11.6  369.  92 7 130.3
2012   2 22  12.0  369.  92 8 130.3
2012   2 23  10.5  361.  92 1 130.3
2012   3  0  11.3  403. 120-7 130.2
2012   3  1  10.3  412. 120   -14 130.2
2012   3  2   8.8  419. 120   -18 130.2
2012   3  3   8.3  412. 120   -23 130.2
2012   3  4   8.0  408. 120   -25 130.2
2012   3  5   7.0  380. 120   -28 130.2
2012   3  6   6.9  374. 120   -29 130.2
2012   3  7   6.9  372. 120   -30 130.2
2012   3  8   7.1  365. 120   -32 130.2
2012   3  9   6.8  376. 120   -35 130.2
2012   3 10   6.7  380. 120   -35 130.2
2012   3 11   6.4  381. 120   -30 130.2
2012   3 12   5.9  401. 120   -26 130.2
2012   3 13   5.9  405. 120   -23 130.2
2012   3 14   5.9  413. 120   -20 130.2
2012   3 15   5.9  406. 120   -20 130.2
2012   3 16   6.3  427. 120   -20 130.2
2012   3 17   5.9  424. 120   -19 130.2
2012   3 18   4.8  390. 120   -16 130.2
2012   3 19   4.8  374. 120   -15 130.2
2012   3 20   4.8  374. 120   -15 130.2
2012   3 21   5.1  378. 120   -18 130.2
2012   3 22   4.9  375. 120   -19 130.2
2012   3 23   4.7  364. 120   -17 130.2
2012   4  0   4.3  359. 126   -17 131.6
2012   4  1   4.3  359. 126   -15 131.6
2012   4  2   4.2  358. 126   -13 131.6
2012   4  3   3.8  359. 126   -13 131.6
2012   4  4   3.8  358. 126   -13 131.6
2012   4  5   3.7  359. 126   -14 131.6
2012   4  6   3.9  361. 126   -13 131.6
2012   4  7   3.7  364. 126   -13 131.6
2012   4  8   3.7  366. 126   -12 131.6
2012   4  9   3.8  363. 126   -10 131.6
2012   4 10   3.5  363. 126-8 131.6
2012   4 11   3.0  352. 126   -10 131.6
2012   4 12   3.1  348. 126   -12 131.6
2012   4 13   3.3  340. 126-9 131.6
2012   4 14   4.0  343. 126-8 131.6
2012   4 15   4.2  343. 126-7 131.6
2012   4 16   3.8  336. 126-5 131.6
2012   4 17   3.9  334. 126-6 131.6
2012   4 18   3.8  329. 126-5 131.6
2012   4 19   3.8  326. 126-4 131.6
2012   4 20   4.3  337. 126-3 131.6
2012   4 21   3.9  331. 126 0 131.6
2012   4 22   3.8  322. 126-1 131.6
2012   4 23   3.5  331. 126-1 131.6
2012   5  0   3.9  312. 109-3 136.6
2012   5  1   3.6  311. 109-1 136.6
2012   5  2   3.7  312. 109 0 136.6
2012   5  3   3.8  308. 109 0 136.6
2012   5  4   4.0  305. 109 2 136.6
2012   5  5   4.5  309. 109 2 136.6
2012   5  6   3.5  314. 109 3 136.6
2012   5  7   3.6  305. 109 2 136.6
2012   5  8   4.3  307. 109 2 136.6
2012   5  9   4.6  316. 109 1 136.6
2012   5 10   5.0  321. 109-4 136.6
2012   5 11   5.1  321. 109-6 136.6
2012   5 12   4.6  326. 109-4 136.6
2012   5 13   5.7  321. 109-2 136.6
2012   5 14   5.0  316. 109 1 136.6
2012   5 15   4.6  315. 109 2 136.6
2012   5 16   5.5  321. 109 7 136.6
2012   5 17   7.2  327. 109 7 136.6
2012   5 18   9.2  329. 109 3 136.6
2012   5 19   9.4  341. 109 3 136.6
2012   5 20   9.2  345. 109 8 136.6
2012   5 21   9.8  344. 109 9 136.6
2012   5 22   9.8  341. 10910 136.6
2012   5 23  10.0  351. 10915 136.6
2012   6  0  10.4  356. 11312 131.0
2012   6  1   9.1  360. 11310 131.0
2012   6  2   6.6  392. 11310 131.0
2012   6  3

Re: [R] code for year month day hr format

2024-06-16 Thread Jibrin Alhassan
Hello Rui,
Your patience is indeed amazing. Your script tested as shown below worked
perfectly well.
df1 <- read.table(text = "YEAR DOY HR   IMF  SW   SSNDst f10.7
2012 215  4   5.1  371. 143-4 138.6 ", header = TRUE)
with(df1, paste(YEAR, DOY)) |> as.Date(format = "%Y %j")
df1$Date <- with(df1, paste(YEAR, DOY)) |> as.Date(format = "%Y %j")
df1 <- df1[-(1:2)]
df1 <- df1[c(ncol(df1), 1:(ncol(df1) - 1L))]
head(df1).
But  I have 43,849 data points. Your script only generated one. Help me
with a script that can handle the whole data points. I have tried following
your tested solution but was unsuccessful. My regards.
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Sun, Jun 16, 2024 at 8:33 AM Rui Barradas  wrote:

> Às 21:42 de 15/06/2024, Jibrin Alhassan escreveu:
> > Thank you Rui. I ran the following script
> > df1 <- read.table("solar_hour", header = TRUE)
> > df1$date <- as.Date(paste(df1$year, df1$hour),
> >   format = "%Y %j",
> > origin = "2012-08-01-0")
> > df2 <- df1[c("date", "IMF", "SWS", "SSN", "Dst", "f10")]
> > head(df1)
> > #To display all the rows
> >   print(df2).
> > It gave me this error message
> >> source ("script.R")
> > Error in `$<-.data.frame`(`*tmp*`, date, value = numeric(0)) :
> >replacement has 0 rows, data has 38735
> >> print(df2)
> > Error: object 'df2' not found
> >> My data is an hourly data but desire to have the date as
> > yearmonthday   hour
> > 2012   08 01 01
> > 2012   08 01 02
> > 2012   0801  03 etc
> > Thanks.
> >
> > *Jibrin Adejoh Alhassan (Ph.D)*
> > Department of Physics and Astronomy,
> > University of Nigeria, Nsukka
> >
> >
> > On Sat, Jun 15, 2024 at 8:34 PM Rui Barradas 
> wrote:
> >
> >> Às 20:00 de 15/06/2024, Jibrin Alhassan escreveu:
> >>> I have solar-geophysical data e.g as blow:
> >>> YEAR DOY HR   IMF  SW   SSNDst f10.7
> >>> 2012 214  0   3.4  403. 132-9 154.6
> >>> 2012 214  1   3.7  388. 132   -10 154.6
> >>> 2012 214  2   3.7  383. 132   -10 154.6
> >>> 2012 214  3   3.7  391. 132-9 154.6
> >>> 2012 214  4   4.2  399. 132-7 154.6
> >>> 2012 214  5   4.1  411. 132-6 154.6
> >>> 2012 214  6   4.0  407. 132-6 154.6
> >>> 2012 214  7   4.2  404. 132-4 154.6
> >>> 2012 214  8   4.3  405. 132-6 154.6
> >>> 2012 214  9   4.4  409. 132-6 154.6
> >>> 2012 214 10   4.4  401. 132-6 154.6
> >>> 2012 214 11   4.5  385. 132-7 154.6
> >>> 2012 214 12   4.7  377. 132-8 154.6
> >>> 2012 214 13   4.7  382. 132-6 154.6
> >>> 2012 214 14   4.3  396. 132-4 154.6
> >>> 2012 214 15   4.1  384. 132-2 154.6
> >>> 2012 214 16   4.0  382. 132-1 154.6
> >>> 2012 214 17   3.9  397. 132 0 154.6
> >>> 2012 214 18   3.8  390. 132 1 154.6
> >>> 2012 214 19   4.2  400. 132 2 154.6
> >>> 2012 214 20   4.6  408. 132 1 154.6
> >>> 2012 214 21   4.8  401. 132-3 154.6
> >>> 2012 214 22   4.9  395. 132-5 154.6
> >>> 2012 214 23   5.0  386. 132-1 154.6
> >>> 2012 215  0   5.0  377. 143-1 138.6
> >>> 2012 215  1   4.9  384. 143-2 138.6
> >>> 2012 215  2   4.9  390. 143-4 138.6
> >>> 2012 215  3   4.9  372. 143-6 138.6
> >>> 2012 215  4   5.1  371. 143-4 138.6
> >>> I want to process it to be of the format as shown below
> >>>y   m  d  hr imf  sws  ssnDst f10.7
> >>> 2012-08-01 10 3.4  403. 132-9 154.6
> >>> 2012-08-01 12 3.7  388. 132   -10 154.6
> >>> 2012-08-01 15 3.7  383. 132   -10 154.6
> >>> 2012-08-01 17 3.7  391. 132-9 154.6
> >>> I want to request an R code to accomplish this task. Thanks for your
> >> time.
> >>> *Jibrin Adejoh Alhassan (Ph.D)*
> >>> Department of Physics and Astronomy,
> >>> University of Nigeria, Nsukka
> >>>
> >>>[[alternative HTML version deleted]]
> >>>
> >>> __
> >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >> Hello,
> >>
> >> To create a date column, paste the first two columns and coerce to class
> >> "Date" with conversion specifications %Y for the 4 digit year and %j for
> >> the day of year. See
> >>
> >> help("strptime")
> >>
> >>
> >>
> >> df1 <- read.table(text = "YEAR DOY HR   IMF  SW   SSNDst f10.7
> >> 2012 214  0   3.4  403. 132-9 154.6
> >> 2012 214  1   3.7  388. 132   -10 154.6
> >> 2012 214  2   3.7  383. 132   -10 154.6
> >> 2012 214  3   3.7  391. 132-9 154.6
> >> 2012 214  4   4.2  399. 132-7 154.6
> >> 2012 214  5   4.1  411. 132-6 154.6
> >> 2012 214  6   4.0  407. 132-6 154.6
> >> 2012 214  7   4.2  404. 132-4 154.6
> >> 2012 214  8   4.3  405. 132-6 154.6
> >> 2012 214  9   4.4  409. 132-6 154.6
> >> 2012 214 10   4.4  401. 132-6 154.6
> >> 2012 214 11   4.5  385. 132   

Re: [R] code for year month day hr format

2024-06-16 Thread Rolf Turner


On Sun, 16 Jun 2024 08:33:03 +0100
Rui Barradas  wrote:



> Hello,
> 
> There is an error in your new code:
> 
> 
> paste YEAR with DOY, not with HR.
> 
> 
> As for the rest, is your real data like the one you posted before?
> If it is then I don't see anything wrong with my (tested) solution.
> 
> 
> Hope this helps,
> 
> Rui Barradas

I never cease to be impressed and indeed amazed by Rui's apparently
inexhaustible patience.

cheers,

Rolf Turner

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
 +64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] code for year month day hr format

2024-06-16 Thread Rui Barradas

Às 21:42 de 15/06/2024, Jibrin Alhassan escreveu:

Thank you Rui. I ran the following script
df1 <- read.table("solar_hour", header = TRUE)
df1$date <- as.Date(paste(df1$year, df1$hour),
  format = "%Y %j",
origin = "2012-08-01-0")
df2 <- df1[c("date", "IMF", "SWS", "SSN", "Dst", "f10")]
head(df1)
#To display all the rows
  print(df2).
It gave me this error message

source ("script.R")

Error in `$<-.data.frame`(`*tmp*`, date, value = numeric(0)) :
   replacement has 0 rows, data has 38735

print(df2)

Error: object 'df2' not found

My data is an hourly data but desire to have the date as

yearmonthday   hour
2012   08 01 01
2012   08 01 02
2012   0801  03 etc
Thanks.

*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Sat, Jun 15, 2024 at 8:34 PM Rui Barradas  wrote:


Às 20:00 de 15/06/2024, Jibrin Alhassan escreveu:

I have solar-geophysical data e.g as blow:
YEAR DOY HR   IMF  SW   SSNDst f10.7
2012 214  0   3.4  403. 132-9 154.6
2012 214  1   3.7  388. 132   -10 154.6
2012 214  2   3.7  383. 132   -10 154.6
2012 214  3   3.7  391. 132-9 154.6
2012 214  4   4.2  399. 132-7 154.6
2012 214  5   4.1  411. 132-6 154.6
2012 214  6   4.0  407. 132-6 154.6
2012 214  7   4.2  404. 132-4 154.6
2012 214  8   4.3  405. 132-6 154.6
2012 214  9   4.4  409. 132-6 154.6
2012 214 10   4.4  401. 132-6 154.6
2012 214 11   4.5  385. 132-7 154.6
2012 214 12   4.7  377. 132-8 154.6
2012 214 13   4.7  382. 132-6 154.6
2012 214 14   4.3  396. 132-4 154.6
2012 214 15   4.1  384. 132-2 154.6
2012 214 16   4.0  382. 132-1 154.6
2012 214 17   3.9  397. 132 0 154.6
2012 214 18   3.8  390. 132 1 154.6
2012 214 19   4.2  400. 132 2 154.6
2012 214 20   4.6  408. 132 1 154.6
2012 214 21   4.8  401. 132-3 154.6
2012 214 22   4.9  395. 132-5 154.6
2012 214 23   5.0  386. 132-1 154.6
2012 215  0   5.0  377. 143-1 138.6
2012 215  1   4.9  384. 143-2 138.6
2012 215  2   4.9  390. 143-4 138.6
2012 215  3   4.9  372. 143-6 138.6
2012 215  4   5.1  371. 143-4 138.6
I want to process it to be of the format as shown below
   y   m  d  hr imf  sws  ssnDst f10.7
2012-08-01 10 3.4  403. 132-9 154.6
2012-08-01 12 3.7  388. 132   -10 154.6
2012-08-01 15 3.7  383. 132   -10 154.6
2012-08-01 17 3.7  391. 132-9 154.6
I want to request an R code to accomplish this task. Thanks for your

time.

*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka

   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.

Hello,

To create a date column, paste the first two columns and coerce to class
"Date" with conversion specifications %Y for the 4 digit year and %j for
the day of year. See

help("strptime")



df1 <- read.table(text = "YEAR DOY HR   IMF  SW   SSNDst f10.7
2012 214  0   3.4  403. 132-9 154.6
2012 214  1   3.7  388. 132   -10 154.6
2012 214  2   3.7  383. 132   -10 154.6
2012 214  3   3.7  391. 132-9 154.6
2012 214  4   4.2  399. 132-7 154.6
2012 214  5   4.1  411. 132-6 154.6
2012 214  6   4.0  407. 132-6 154.6
2012 214  7   4.2  404. 132-4 154.6
2012 214  8   4.3  405. 132-6 154.6
2012 214  9   4.4  409. 132-6 154.6
2012 214 10   4.4  401. 132-6 154.6
2012 214 11   4.5  385. 132-7 154.6
2012 214 12   4.7  377. 132-8 154.6
2012 214 13   4.7  382. 132-6 154.6
2012 214 14   4.3  396. 132-4 154.6
2012 214 15   4.1  384. 132-2 154.6
2012 214 16   4.0  382. 132-1 154.6
2012 214 17   3.9  397. 132 0 154.6
2012 214 18   3.8  390. 132 1 154.6
2012 214 19   4.2  400. 132 2 154.6
2012 214 20   4.6  408. 132 1 154.6
2012 214 21   4.8  401. 132-3 154.6
2012 214 22   4.9  395. 132-5 154.6
2012 214 23   5.0  386. 132-1 154.6
2012 215  0   5.0  377. 143-1 138.6
2012 215  1   4.9  384. 143-2 138.6
2012 215  2   4.9  390. 143-4 138.6
2012 215  3   4.9  372. 143-6 138.6
2012 215  4   5.1  371. 143-4 138.6", header = TRUE)


with(df1, paste(YEAR, DOY)) |> as.Date(format = "%Y %j")
#>  [1] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
#>  [6] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
#> [11] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
#> [16] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
#> [21] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-02"
#> [26] "2012-08-02" "2012-08-02" "2012-08-02" "2012-08-02"

# now create the column
df1$Date <- with(df1, paste(YEAR, DOY)) |> as.Date(format = "%Y %j")
# remove the columns 

Re: [R] code for year month day hr format

2024-06-15 Thread Jeff Newmiller via R-help
Please run your sequence of R statements one at a time so you can tell where 
the problem is. Only "run a script" after the code works one line at a time. 
There are too many places where things can go wrong otherwise.

Is your file being read in properly? Is the filename correct? was the header 
properly recognized?

I see something odd about the input you are providing to the "origin" argument 
to the as.Date function.

On June 15, 2024 1:42:45 PM PDT, Jibrin Alhassan  
wrote:
>Thank you Rui. I ran the following script
>df1 <- read.table("solar_hour", header = TRUE)
>df1$date <- as.Date(paste(df1$year, df1$hour),
> format = "%Y %j",
>origin = "2012-08-01-0")
>df2 <- df1[c("date", "IMF", "SWS", "SSN", "Dst", "f10")]
>head(df1)
>#To display all the rows
> print(df2).
>It gave me this error message
>> source ("script.R")
>Error in `$<-.data.frame`(`*tmp*`, date, value = numeric(0)) :
>  replacement has 0 rows, data has 38735
>> print(df2)
>Error: object 'df2' not found
>> My data is an hourly data but desire to have the date as
>yearmonthday   hour
>2012   08 01 01
>2012   08 01 02
>2012   0801  03 etc
>Thanks.
>
>*Jibrin Adejoh Alhassan (Ph.D)*
>Department of Physics and Astronomy,
>University of Nigeria, Nsukka
>
>
>On Sat, Jun 15, 2024 at 8:34 PM Rui Barradas  wrote:
>
>> Às 20:00 de 15/06/2024, Jibrin Alhassan escreveu:
>> > I have solar-geophysical data e.g as blow:
>> > YEAR DOY HR   IMF  SW   SSNDst f10.7
>> > 2012 214  0   3.4  403. 132-9 154.6
>> > 2012 214  1   3.7  388. 132   -10 154.6
>> > 2012 214  2   3.7  383. 132   -10 154.6
>> > 2012 214  3   3.7  391. 132-9 154.6
>> > 2012 214  4   4.2  399. 132-7 154.6
>> > 2012 214  5   4.1  411. 132-6 154.6
>> > 2012 214  6   4.0  407. 132-6 154.6
>> > 2012 214  7   4.2  404. 132-4 154.6
>> > 2012 214  8   4.3  405. 132-6 154.6
>> > 2012 214  9   4.4  409. 132-6 154.6
>> > 2012 214 10   4.4  401. 132-6 154.6
>> > 2012 214 11   4.5  385. 132-7 154.6
>> > 2012 214 12   4.7  377. 132-8 154.6
>> > 2012 214 13   4.7  382. 132-6 154.6
>> > 2012 214 14   4.3  396. 132-4 154.6
>> > 2012 214 15   4.1  384. 132-2 154.6
>> > 2012 214 16   4.0  382. 132-1 154.6
>> > 2012 214 17   3.9  397. 132 0 154.6
>> > 2012 214 18   3.8  390. 132 1 154.6
>> > 2012 214 19   4.2  400. 132 2 154.6
>> > 2012 214 20   4.6  408. 132 1 154.6
>> > 2012 214 21   4.8  401. 132-3 154.6
>> > 2012 214 22   4.9  395. 132-5 154.6
>> > 2012 214 23   5.0  386. 132-1 154.6
>> > 2012 215  0   5.0  377. 143-1 138.6
>> > 2012 215  1   4.9  384. 143-2 138.6
>> > 2012 215  2   4.9  390. 143-4 138.6
>> > 2012 215  3   4.9  372. 143-6 138.6
>> > 2012 215  4   5.1  371. 143-4 138.6
>> > I want to process it to be of the format as shown below
>> >   y   m  d  hr imf  sws  ssnDst f10.7
>> > 2012-08-01 10 3.4  403. 132-9 154.6
>> > 2012-08-01 12 3.7  388. 132   -10 154.6
>> > 2012-08-01 15 3.7  383. 132   -10 154.6
>> > 2012-08-01 17 3.7  391. 132-9 154.6
>> > I want to request an R code to accomplish this task. Thanks for your
>> time.
>> > *Jibrin Adejoh Alhassan (Ph.D)*
>> > Department of Physics and Astronomy,
>> > University of Nigeria, Nsukka
>> >
>> >   [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> Hello,
>>
>> To create a date column, paste the first two columns and coerce to class
>> "Date" with conversion specifications %Y for the 4 digit year and %j for
>> the day of year. See
>>
>> help("strptime")
>>
>>
>>
>> df1 <- read.table(text = "YEAR DOY HR   IMF  SW   SSNDst f10.7
>> 2012 214  0   3.4  403. 132-9 154.6
>> 2012 214  1   3.7  388. 132   -10 154.6
>> 2012 214  2   3.7  383. 132   -10 154.6
>> 2012 214  3   3.7  391. 132-9 154.6
>> 2012 214  4   4.2  399. 132-7 154.6
>> 2012 214  5   4.1  411. 132-6 154.6
>> 2012 214  6   4.0  407. 132-6 154.6
>> 2012 214  7   4.2  404. 132-4 154.6
>> 2012 214  8   4.3  405. 132-6 154.6
>> 2012 214  9   4.4  409. 132-6 154.6
>> 2012 214 10   4.4  401. 132-6 154.6
>> 2012 214 11   4.5  385. 132-7 154.6
>> 2012 214 12   4.7  377. 132-8 154.6
>> 2012 214 13   4.7  382. 132-6 154.6
>> 2012 214 14   4.3  396. 132-4 154.6
>> 2012 214 15   4.1  384. 132-2 154.6
>> 2012 214 16   4.0  382. 132-1 154.6
>> 2012 214 17   3.9  397. 132 0 154.6
>> 2012 214 18   3.8  390. 132 1 154.6
>> 2012 214 19   4.2  400. 132 2 154.6
>> 2012 214 20   4.6  408. 132 1 154.6
>> 2012 214 21   4.8  401. 132-3 154.6
>> 2012 214 22   4.9  395. 132-5 154.6
>> 2012 214 23   5.0  386. 132-1 154.6
>> 2012 215  0 

Re: [R] code for year month day hr format

2024-06-15 Thread Jibrin Alhassan
Thank you Rui. I ran the following script
df1 <- read.table("solar_hour", header = TRUE)
df1$date <- as.Date(paste(df1$year, df1$hour),
 format = "%Y %j",
origin = "2012-08-01-0")
df2 <- df1[c("date", "IMF", "SWS", "SSN", "Dst", "f10")]
head(df1)
#To display all the rows
 print(df2).
It gave me this error message
> source ("script.R")
Error in `$<-.data.frame`(`*tmp*`, date, value = numeric(0)) :
  replacement has 0 rows, data has 38735
> print(df2)
Error: object 'df2' not found
> My data is an hourly data but desire to have the date as
yearmonthday   hour
2012   08 01 01
2012   08 01 02
2012   0801  03 etc
Thanks.

*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Sat, Jun 15, 2024 at 8:34 PM Rui Barradas  wrote:

> Às 20:00 de 15/06/2024, Jibrin Alhassan escreveu:
> > I have solar-geophysical data e.g as blow:
> > YEAR DOY HR   IMF  SW   SSNDst f10.7
> > 2012 214  0   3.4  403. 132-9 154.6
> > 2012 214  1   3.7  388. 132   -10 154.6
> > 2012 214  2   3.7  383. 132   -10 154.6
> > 2012 214  3   3.7  391. 132-9 154.6
> > 2012 214  4   4.2  399. 132-7 154.6
> > 2012 214  5   4.1  411. 132-6 154.6
> > 2012 214  6   4.0  407. 132-6 154.6
> > 2012 214  7   4.2  404. 132-4 154.6
> > 2012 214  8   4.3  405. 132-6 154.6
> > 2012 214  9   4.4  409. 132-6 154.6
> > 2012 214 10   4.4  401. 132-6 154.6
> > 2012 214 11   4.5  385. 132-7 154.6
> > 2012 214 12   4.7  377. 132-8 154.6
> > 2012 214 13   4.7  382. 132-6 154.6
> > 2012 214 14   4.3  396. 132-4 154.6
> > 2012 214 15   4.1  384. 132-2 154.6
> > 2012 214 16   4.0  382. 132-1 154.6
> > 2012 214 17   3.9  397. 132 0 154.6
> > 2012 214 18   3.8  390. 132 1 154.6
> > 2012 214 19   4.2  400. 132 2 154.6
> > 2012 214 20   4.6  408. 132 1 154.6
> > 2012 214 21   4.8  401. 132-3 154.6
> > 2012 214 22   4.9  395. 132-5 154.6
> > 2012 214 23   5.0  386. 132-1 154.6
> > 2012 215  0   5.0  377. 143-1 138.6
> > 2012 215  1   4.9  384. 143-2 138.6
> > 2012 215  2   4.9  390. 143-4 138.6
> > 2012 215  3   4.9  372. 143-6 138.6
> > 2012 215  4   5.1  371. 143-4 138.6
> > I want to process it to be of the format as shown below
> >   y   m  d  hr imf  sws  ssnDst f10.7
> > 2012-08-01 10 3.4  403. 132-9 154.6
> > 2012-08-01 12 3.7  388. 132   -10 154.6
> > 2012-08-01 15 3.7  383. 132   -10 154.6
> > 2012-08-01 17 3.7  391. 132-9 154.6
> > I want to request an R code to accomplish this task. Thanks for your
> time.
> > *Jibrin Adejoh Alhassan (Ph.D)*
> > Department of Physics and Astronomy,
> > University of Nigeria, Nsukka
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> Hello,
>
> To create a date column, paste the first two columns and coerce to class
> "Date" with conversion specifications %Y for the 4 digit year and %j for
> the day of year. See
>
> help("strptime")
>
>
>
> df1 <- read.table(text = "YEAR DOY HR   IMF  SW   SSNDst f10.7
> 2012 214  0   3.4  403. 132-9 154.6
> 2012 214  1   3.7  388. 132   -10 154.6
> 2012 214  2   3.7  383. 132   -10 154.6
> 2012 214  3   3.7  391. 132-9 154.6
> 2012 214  4   4.2  399. 132-7 154.6
> 2012 214  5   4.1  411. 132-6 154.6
> 2012 214  6   4.0  407. 132-6 154.6
> 2012 214  7   4.2  404. 132-4 154.6
> 2012 214  8   4.3  405. 132-6 154.6
> 2012 214  9   4.4  409. 132-6 154.6
> 2012 214 10   4.4  401. 132-6 154.6
> 2012 214 11   4.5  385. 132-7 154.6
> 2012 214 12   4.7  377. 132-8 154.6
> 2012 214 13   4.7  382. 132-6 154.6
> 2012 214 14   4.3  396. 132-4 154.6
> 2012 214 15   4.1  384. 132-2 154.6
> 2012 214 16   4.0  382. 132-1 154.6
> 2012 214 17   3.9  397. 132 0 154.6
> 2012 214 18   3.8  390. 132 1 154.6
> 2012 214 19   4.2  400. 132 2 154.6
> 2012 214 20   4.6  408. 132 1 154.6
> 2012 214 21   4.8  401. 132-3 154.6
> 2012 214 22   4.9  395. 132-5 154.6
> 2012 214 23   5.0  386. 132-1 154.6
> 2012 215  0   5.0  377. 143-1 138.6
> 2012 215  1   4.9  384. 143-2 138.6
> 2012 215  2   4.9  390. 143-4 138.6
> 2012 215  3   4.9  372. 143-6 138.6
> 2012 215  4   5.1  371. 143-4 138.6", header = TRUE)
>
>
> with(df1, paste(YEAR, DOY)) |> as.Date(format = "%Y %j")
> #>  [1] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
> #>  [6] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
> #> [11] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
> #> [16] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
> #> [21] "2012-08-01" "2

Re: [R] code for year month day hr format

2024-06-15 Thread Ebert,Timothy Aaron
library(lubridate)
library(dplyr)
df1 <- read.table(text = "YEAR DOY HR   IMF  SW   SSNDst f10.7
2012 214  0   3.4  403. 132-9 154.6
2012 214  1   3.7  388. 132   -10 154.6
2012 214  2   3.7  383. 132   -10 154.6
2012 214  3   3.7  391. 132-9 154.6
2012 215  4   5.1  371. 143-4 138.6", header = TRUE)

df_date <- df1 |>
  mutate(
date_date = as.Date(DOY-1, origin=paste0(YEAR, "-01-01")),
date_chr = format(date_date, "%Y-%m-%d")
  )
df_date <- df_date[,-c(1:2,9)]
df_date <- df_date[c(ncol(df_date), 1:(ncol(df_date) - 1L))]

# That is the form of the data in the example.
# But there may be a conflict in the column names versus the data shown where 
Y, M, and D were separate versus "Y_M_D" which would be the name of one column 
indicating the desired order.
# If you want Y, M, and D in different columns then this could work:
df_date2 <- df1 |>
  mutate(
date_date = as.Date(DOY-1, origin=paste0(YEAR, "-01-01")),
date_chr = format(date_date, "%Y-%m-%d")
  )
df_date2$M <- month(df_date2$date_date)
df_date2$D <- day(df_date2$date_date)
# drop unused columns
df_date2 <- df_date2[ , -c(2, 9, 10)]
# Reorganize columns to desired locations
df_date2 <- df_date2[, c("YEAR", "M", "D", "IMF", "SW", "SSN", "Dst", "f10.7")]
# Rename "Year" to "Y"
names(df_date2)[names(df_date2) == "YEAR"] <- "Y"


Tim
-Original Message-
From: R-help  On Behalf Of Jibrin Alhassan
Sent: Saturday, June 15, 2024 3:01 PM
To: R-help 
Subject: [R] code for year month day hr format

[External Email]

I have solar-geophysical data e.g as blow:
YEAR DOY HR   IMF  SW   SSNDst f10.7
2012 214  0   3.4  403. 132-9 154.6
2012 214  1   3.7  388. 132   -10 154.6
2012 214  2   3.7  383. 132   -10 154.6
2012 214  3   3.7  391. 132-9 154.6
2012 214  4   4.2  399. 132-7 154.6
2012 214  5   4.1  411. 132-6 154.6
2012 214  6   4.0  407. 132-6 154.6
2012 214  7   4.2  404. 132-4 154.6
2012 214  8   4.3  405. 132-6 154.6
2012 214  9   4.4  409. 132-6 154.6
2012 214 10   4.4  401. 132-6 154.6
2012 214 11   4.5  385. 132-7 154.6
2012 214 12   4.7  377. 132-8 154.6
2012 214 13   4.7  382. 132-6 154.6
2012 214 14   4.3  396. 132-4 154.6
2012 214 15   4.1  384. 132-2 154.6
2012 214 16   4.0  382. 132-1 154.6
2012 214 17   3.9  397. 132 0 154.6
2012 214 18   3.8  390. 132 1 154.6
2012 214 19   4.2  400. 132 2 154.6
2012 214 20   4.6  408. 132 1 154.6
2012 214 21   4.8  401. 132-3 154.6
2012 214 22   4.9  395. 132-5 154.6
2012 214 23   5.0  386. 132-1 154.6
2012 215  0   5.0  377. 143-1 138.6
2012 215  1   4.9  384. 143-2 138.6
2012 215  2   4.9  390. 143-4 138.6
2012 215  3   4.9  372. 143-6 138.6
2012 215  4   5.1  371. 143-4 138.6
I want to process it to be of the format as shown below
 y   m  d  hr imf  sws  ssnDst f10.7
2012-08-01 10 3.4  403. 132-9 154.6
2012-08-01 12 3.7  388. 132   -10 154.6
2012-08-01 15 3.7  383. 132   -10 154.6
2012-08-01 17 3.7  391. 132-9 154.6
I want to request an R code to accomplish this task. Thanks for your time.
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.r-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] code for year month day hr format

2024-06-15 Thread Rui Barradas

Às 20:00 de 15/06/2024, Jibrin Alhassan escreveu:

I have solar-geophysical data e.g as blow:
YEAR DOY HR   IMF  SW   SSNDst f10.7
2012 214  0   3.4  403. 132-9 154.6
2012 214  1   3.7  388. 132   -10 154.6
2012 214  2   3.7  383. 132   -10 154.6
2012 214  3   3.7  391. 132-9 154.6
2012 214  4   4.2  399. 132-7 154.6
2012 214  5   4.1  411. 132-6 154.6
2012 214  6   4.0  407. 132-6 154.6
2012 214  7   4.2  404. 132-4 154.6
2012 214  8   4.3  405. 132-6 154.6
2012 214  9   4.4  409. 132-6 154.6
2012 214 10   4.4  401. 132-6 154.6
2012 214 11   4.5  385. 132-7 154.6
2012 214 12   4.7  377. 132-8 154.6
2012 214 13   4.7  382. 132-6 154.6
2012 214 14   4.3  396. 132-4 154.6
2012 214 15   4.1  384. 132-2 154.6
2012 214 16   4.0  382. 132-1 154.6
2012 214 17   3.9  397. 132 0 154.6
2012 214 18   3.8  390. 132 1 154.6
2012 214 19   4.2  400. 132 2 154.6
2012 214 20   4.6  408. 132 1 154.6
2012 214 21   4.8  401. 132-3 154.6
2012 214 22   4.9  395. 132-5 154.6
2012 214 23   5.0  386. 132-1 154.6
2012 215  0   5.0  377. 143-1 138.6
2012 215  1   4.9  384. 143-2 138.6
2012 215  2   4.9  390. 143-4 138.6
2012 215  3   4.9  372. 143-6 138.6
2012 215  4   5.1  371. 143-4 138.6
I want to process it to be of the format as shown below
  y   m  d  hr imf  sws  ssnDst f10.7
2012-08-01 10 3.4  403. 132-9 154.6
2012-08-01 12 3.7  388. 132   -10 154.6
2012-08-01 15 3.7  383. 132   -10 154.6
2012-08-01 17 3.7  391. 132-9 154.6
I want to request an R code to accomplish this task. Thanks for your time.
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Hello,

To create a date column, paste the first two columns and coerce to class 
"Date" with conversion specifications %Y for the 4 digit year and %j for 
the day of year. See


help("strptime")



df1 <- read.table(text = "YEAR DOY HR   IMF  SW   SSNDst f10.7
2012 214  0   3.4  403. 132-9 154.6
2012 214  1   3.7  388. 132   -10 154.6
2012 214  2   3.7  383. 132   -10 154.6
2012 214  3   3.7  391. 132-9 154.6
2012 214  4   4.2  399. 132-7 154.6
2012 214  5   4.1  411. 132-6 154.6
2012 214  6   4.0  407. 132-6 154.6
2012 214  7   4.2  404. 132-4 154.6
2012 214  8   4.3  405. 132-6 154.6
2012 214  9   4.4  409. 132-6 154.6
2012 214 10   4.4  401. 132-6 154.6
2012 214 11   4.5  385. 132-7 154.6
2012 214 12   4.7  377. 132-8 154.6
2012 214 13   4.7  382. 132-6 154.6
2012 214 14   4.3  396. 132-4 154.6
2012 214 15   4.1  384. 132-2 154.6
2012 214 16   4.0  382. 132-1 154.6
2012 214 17   3.9  397. 132 0 154.6
2012 214 18   3.8  390. 132 1 154.6
2012 214 19   4.2  400. 132 2 154.6
2012 214 20   4.6  408. 132 1 154.6
2012 214 21   4.8  401. 132-3 154.6
2012 214 22   4.9  395. 132-5 154.6
2012 214 23   5.0  386. 132-1 154.6
2012 215  0   5.0  377. 143-1 138.6
2012 215  1   4.9  384. 143-2 138.6
2012 215  2   4.9  390. 143-4 138.6
2012 215  3   4.9  372. 143-6 138.6
2012 215  4   5.1  371. 143-4 138.6", header = TRUE)


with(df1, paste(YEAR, DOY)) |> as.Date(format = "%Y %j")
#>  [1] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
#>  [6] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
#> [11] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
#> [16] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01"
#> [21] "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-01" "2012-08-02"
#> [26] "2012-08-02" "2012-08-02" "2012-08-02" "2012-08-02"

# now create the column
df1$Date <- with(df1, paste(YEAR, DOY)) |> as.Date(format = "%Y %j")
# remove the columns no longer needed
df1 <- df1[-(1:2)]
# relocate the new date column
df1 <- df1[c(ncol(df1), 1:(ncol(df1) - 1L))]
head(df1)
#> Date HR IMF  SW SSN Dst f10.7
#> 1 2012-08-01  0 3.4 403 132  -9 154.6
#> 2 2012-08-01  1 3.7 388 132 -10 154.6
#> 3 2012-08-01  2 3.7 383 132 -10 154.6
#> 4 2012-08-01  3 3.7 391 132  -9 154.6
#> 5 2012-08-01  4 4.2 399 132  -7 154.6
#> 6 2012-08-01  5 4.1 411 132  -6 154.6


Hope this helps,

Rui Barradas


--
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença 
de vírus.
www.avg.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.