[R] code for year month day hr format

Jibrin Alhassan j|br|n@@|h@@@@n @end|ng |rom unn@edu@ng
Mon Jun 17 08:53:00 CEST 2024


Part of it is pasted below
YEAR DOY HR    IMF 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.  92    10 130.3
2012   2 17   7.7  369.  92    10 130.3
2012   2 18   9.4  380.  92    14 130.3
2012   2 19  10.6  386.  92    12 130.3
2012   2 20  10.2  378.  92    11 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. 109    10 136.6
2012   5 23  10.0  351. 109    15 136.6
2012   6  0  10.4  356. 113    12 131.0
2012   6  1   9.1  360. 113    10 131.0
2012   6  2   6.6  392. 113    10 131.0
2012   6  3   6.9  418. 113     7 131.0
2012   6  4   6.5  408. 113     4 131.0
2012   6  5   6.6  413. 113     7 131.0
2012   6  6   7.3  428. 113     6 131.0
2012   6  7   7.3  416. 113     4 131.0
2012   6  8   7.0  411. 113     1 131.0
2012   6  9   7.2  415. 113     1 131.0
2012   6 10   7.2  426. 113     0 131.0
2012   6 11   6.5  431. 113    -2 131.0
2012   6 12   6.4  431. 113    -2 131.0
2012   6 13   6.6  435. 113     0 131.0
2012   6 14   6.2  425. 113     2 131.0
2012   6 15   5.7  431. 113     4 131.0
2012   6 16   6.1  431. 113     1 131.0
2012   6 17   5.7  425. 113    -3 131.0
2012   6 18   5.8  431. 113    -1 131.0
2012   6 19   6.4  425. 113     2 131.0
2012   6 20   6.0  434. 113     1 131.0
2012   6 21   6.3  420. 113     0 131.0
2012   6 22   6.3  440. 113    -3 131.0
2012   6 23   6.5  456. 113    -3 131.0
2012   7  0   6.3  435. 113    -5 135.9
2012   7  1   5.9  428. 113    -1 135.9
2012   7  2   5.7  434. 113     1 135.9
2012   7  3   5.3  423. 113     0 135.9
2012   7  4   4.3  417. 113     1 135.9
2012   7  5   5.4  420. 113     0 135.9
2012   7  6   5.7  434. 113     1 135.9
2012   7  7   5.5  423. 113     1 135.9
2012   7  8   4.8  419. 113    -2 135.9
2012   7  9   5.8  421. 113    -6 135.9
2012   7 10   5.3  412. 113    -9 135.9
2012   7 11   4.6  424. 113    -7 135.9
2012   7 12   4.0  439. 113    -3 135.9
2012   7 13   4.8  431. 113    -1 135.9
2012   7 14   5.1  431. 113    -1 135.9
2012   7 15   4.8  427. 113    -1 135.9
2012   7 16   4.7  429. 113    -5 135.9
2012   7 17   5.3  436. 113    -6 135.9
2012   7 18   5.1  426. 113    -5 135.9
2012   7 19   5.2  427. 113    -4 135.9
2012   7 20   4.5  416. 113    -5 135.9
2012   7 21   4.9  409. 113    -4 135.9
2012   7 22   5.0  417. 113    -4 135.9
2012   7 23   5.0  426. 113    -4 135.9
2012   8  0   5.0  433. 104    -2 131.4
2012   8  1   4.9  426. 104    -2 131.4
2012   8  2   4.7  421. 104    -4 131.4
2012   8  3   4.4  417. 104    -5 131.4
2012   8  4   4.3  416. 104    -8 131.4
2012   8  5   4.5  416. 104    -8 131.4
2012   8  6   5.0  419. 104    -6 131.4
2012   8  7   5.4  446. 104    -1 131.4
2012   8  8   5.3  439. 104    -2 131.4
2012   8  9   5.3  432. 104    -4 131.4
2012   8 10   5.4  434. 104    -4 131.4
2012   8 11   5.4  435. 104    -3 131.4
2012   8 12   4.5  421. 104    -4 131.4
2012   8 13   4.5  422. 104    -4 131.4
2012   8 14   5.1  425. 104    -2 131.4
2012   8 15   5.3  429. 104     1 131.4
2012   8 16   5.5  433. 104    -2 131.4
2012   8 17   5.9  440. 104    -2 131.4
2012   8 18   6.6  445. 104    -1 131.4
2012   8 19   6.4  442. 104    -4 131.4
2012   8 20   5.9  434. 104    -6 131.4
2012   8 21   5.3  429. 104    -7 131.4
2012   8 22   4.8  438. 104    -2 131.4
2012   8 23   5.3  427. 104     4 131.4
2012   9  0   5.5  433.  79     8 137.6
2012   9  1   5.2  445.  79     9 137.6
2012   9  2   5.4  439.  79    10 137.6
2012   9  3   5.3  430.  79     7 137.6
2012   9  4   5.1  426.  79    -3 137.6
2012   9  5   4.7  415.  79    -6 137.6
2012   9  6   5.0  412.  79    -4 137.6
2012   9  7   5.2  418.  79    -2 137.6
2012   9  8   5.5  441.  79     2 137.6
2012   9  9   5.1  441.  79     2 137.6
2012   9 10   5.4  430.  79    -2 137.6
2012   9 11   5.3  433.  79    -1 137.6
2012   9 12   5.5  438.  79     5 137.6
2012   9 13   5.4  436.  79     6 137.6
2012   9 14   5.7  440.  79     9 137.6
2012   9 15   5.9  430.  79     9 137.6
2012   9 16   5.8  437.  79     4 137.6
2012   9 17   4.9  431.  79    -3 137.6
2012   9 18   5.3  424.  79    -3 137.6
2012   9 19   5.7  437.  79    -2 137.6
2012   9 20   6.1  427.  79    -4 137.6
2012   9 21   6.0  409.  79    -7 137.6
2012   9 22   6.6  410.  79    -4 137.6
2012   9 23   6.4  432.  79    -1 137.6
2012  10  0   5.9  434.  70     2 124.6
2012  10  1   5.6  424.  70     4 124.6
2012  10  2   4.8  435.  70     7 124.6
2012  10  3   4.6  425.  70     4 124.6
2012  10  4   4.3  424.  70     3 124.6
2012  10  5   5.4  426.  70     2 124.6
2012  10  6   5.5  434.  70     2 124.6
2012  10  7   6.4  435.  70     4 124.6
2012  10  8   6.3  436.  70     1 124.6
2012  10  9   5.2  431.  70    -6 124.6
2012  10 10   4.5  426.  70   -10 124.6
2012  10 11   4.6  435.  70    -9 124.6
2012  10 12   3.4  425.  70    -5 124.6
2012  10 13   4.2  427.  70    -4 124.6
2012  10 14   4.0  432.  70     2 124.6
2012  10 15   5.5  450.  70     7 124.6
2012  10 16   5.9  451.  70     2 124.6
2012  10 17   5.5  445.  70    -3 124.6
2012  10 18   5.8  442.  70    -2 124.6
2012  10 19   5.4  430.  70    -1 124.6
2012  10 20   4.9  427.  70    -1 124.6
2012  10 21   4.0  436.  70     0 124.6
2012  10 22   3.4  445.  70    -1 124.6
2012  10 23   4.5  453.  70     0 124.6
2012  11  0   5.3  438.  63     1 116.1
2012  11  1   5.0  438.  63     3 116.1
2012  11  2   5.3  445.  63     3 116.1
2012  11  3   4.5  451.  63     2 116.1
2012  11  4   5.0  456.  63    -1 116.1
2012  11  5   4.6  459.  63     0 116.1
2012  11  6   5.1  459.  63     1 116.1
2012  11  7   4.0  466.  63     3 116.1
2012  11  8   5.0  478.  63    -1 116.1
2012  11  9   4.6  489.  63    -2 116.1
2012  11 10   4.5  493.  63    -4 116.1
2012  11 11   4.5  494.  63    -1 116.1
2012  11 12   3.6  504.  63     3 116.1
2012  11 13   3.5  496.  63     5 116.1
2012  11 14   3.3  497.  63     7 116.1
2012  11 15   3.0  498.  63     7 116.1
2012  11 16   2.1  503.  63     3 116.1
2012  11 17   2.0  495.  63     0 116.1
2012  11 18   2.5  492.  63    -2 116.1
2012  11 19   2.2  496.  63    -1 116.1
2012  11 20   2.4  489.  63     1 116.1
2012  11 21   2.6  489.  63     3 116.1
2012  11 22   2.6  483.  63     2 116.1
2012  11 23   2.6  478.  63     2 116.1
2012  12  0   2.9  453.  52     3 113.0
2012  12  1   2.2  446.  52     4 113.0
2012  12  2   2.4  442.  52     8 113.0
2012  12  3   2.6  440.  52    10 113.0
2012  12  4   2.2  438.  52    11 113.0
2012  12  5   2.8  438.  52     9 113.0
2012  12  6   2.0  437.  52     8 113.0
2012  12  7   2.4  426.  52     7 113.0
2012  12  8   3.0  423.  52     5 113.0
2012  12  9   3.3  420.  52     4 113.0
2012  12 10   4.0  419.  52     2 113.0
2012  12 11   3.8  412.  52     5 113.0
2012  12 12   4.2  409.  52     4 113.0
2012  12 13   3.5  408.  52     2 113.0
2012  12 14   3.7  404.  52     9 113.0
2012  12 15   4.5  402.  52    15 113.0
2012  12 16   3.6  395.  52    14 113.0
2012  12 17   2.4  392.  52    16 113.0
2012  12 18   5.8  403.  52    27 113.0
2012  12 19   7.6  400.  52    27 113.0
2012  12 20   6.9  418.  52    17 113.0
2012  12 21   6.9  463.  52    10 113.0
2012  12 22   7.3  469.  52     9 113.0
2012  12 23   5.5  482.  52    12 113.0
2012  13  0   7.7  500.  71    10 120.0
2012  13  1   8.7  492.  71    14 120.0
2012  13  2   7.8  513.  71    16 120.0
2012  13  3   7.5  530.  71    11 120.0
2012  13  4   7.1  518.  71     8 120.0
2012  13  5   7.0  524.  71     6 120.0
2012  13  6   5.9  536.  71     8 120.0
2012  13  7   3.6  529.  71     5 120.0
2012  13  8   4.1  510.  71     4 120.0
2012  13  9   3.9  497.  71     3 120.0
2012  13 10   2.4  492.  71     3 120.0
2012  13 11   2.6  485.  71     5 120.0
2012  13 12   2.9  492.  71     5 120.0
2012  13 13   2.6  487.  71     3 120.0
2012  13 14   2.3  478.  71     6 120.0
2012  13 15   3.2  467.  71    11 120.0
2012  13 16   3.4  453.  71    10 120.0
2012  13 17   3.2  452.  71     6 120.0
2012  13 18   3.0  452.  71     2 120.0
2012  13 19   2.8  447.  71     1 120.0
2012  13 20   2.5  439.  71     0 120.0
2012  13 21   2.5  443.  71    -2 120.0
2012  13 22   2.7  442.  71    -3 120.0
2012  13 23   3.0  447.  71    -4 120.0
2012  14  0   3.5  445. 118    -3 128.0
2012  14  1   3.3  440. 118    -1 128.0
2012  14  2   3.1  440. 118     1 128.0
2012  14  3   2.7  446. 118     0 128.0
2012  14  4   2.9  442. 118    -1 128.0
2012  14  5   2.9  437. 118    -2 128.0
2012  14  6   3.3  431. 118    -3 128.0
2012  14  7   2.8  420. 118    -2 128.0
2012  14  8   2.3  409. 118    -2 128.0
2012  14  9   2.2  407. 118     1 128.0
2012  14 10   2.6  405. 118     3 128.0
2012  14 11   2.8  401. 118     4 128.0
2012  14 12   3.2  398. 118     4 128.0
2012  14 13   2.7  400. 118     4 128.0
2012  14 14   1.9  399. 118     5 128.0
2012  14 15   2.4  395. 118     3 128.0
2012  14 16   2.7  389. 118     2 128.0
2012  14 17   2.9  385. 118     0 128.0
2012  14 18   3.2  384. 118     1 128.0
2012  14 19   2.6  380. 118     2 128.0
2012  14 20   2.3  378. 118     1 128.0
2012  14 21   2.1  374. 118     0 128.0
2012  14 22   3.1  367. 118     0 128.0
2012  14 23   4.0  366. 118    -1 128.0
2012  15  0   4.8  363. 149     0 129.2
2012  15  1   4.0  359. 149     2 129.2
2012  15  2   3.4  354. 149     2 129.2
2012  15  3   3.0  349. 149     5 129.2
2012  15  4   2.7  344. 149     7 129.2
2012  15  5   2.4  349. 149    11 129.2
2012  15  6   2.9  343. 149    12 129.2
2012  15  7   3.5  333. 149     7 129.2
2012  15  8   3.6  341. 149     4 129.2
2012  15  9   3.7  345. 149     1 129.2
2012  15 10   3.6  343. 149     2 129.2
2012  15 11   3.6  342. 149     3 129.2
2012  15 12   3.7  340. 149     7 129.2
2012  15 13   3.7  342. 149     8 129.2
2012  15 14   4.1  344. 149     9 129.2
2012  15 15   3.9  345. 149     4 129.2
2012  15 16   4.4  355. 149     8 129.2
2012  15 17   4.7  360. 149    11 129.2
2012  15 18   5.4  359. 149    12 129.2
2012  15 19   6.8  353. 149     8 129.2
2012  15 20   6.6  349. 149     6 129.2
2012  15 21   5.9  364. 149     2 129.2
2012  15 22   5.2  394. 149     1 129.2
2012  15 23   6.3  395. 149     5 129.2
2012  16  0   6.3  385. 154     6 135.1
2012  16  1   6.6  397. 154     2 135.1
2012  16  2   6.7  400. 154     4 135.1
2012  16  3   6.9  396. 154     5 135.1
2012  16  4   7.9  392. 154     5 135.1
2012  16  5   4.6  379. 154    10 135.1
2012  16  6   8.0  365. 154    13 135.1
2012  16  7   6.3  358. 154    16 135.1
2012  16  8   7.9  380. 154    12 135.1
2012  16  9  10.2  391. 154    10 135.1
2012  16 10   8.1  394. 154     8 135.1
2012  16 11  12.1  412. 154    -8 135.1
2012  16 12  13.2  424. 154   -10 135.1
2012  16 13  12.9  433. 154    -8 135.1
2012  16 14   9.3  461. 154    -7 135.1
2012  16 15   6.6  466. 154   -14 135.1
2012  16 16   6.6  493. 154   -11 135.1
2012  16 17   7.4  496. 154    -7 135.1
2012  16 18   6.2  493. 154    -7 135.1
2012  16 19   6.9  492. 154   -13 135.1
2012  16 20   6.8  486. 154   -19 135.1
2012  16 21   5.6  488. 154   -14 135.1
2012  16 22   6.4  464. 154   -11 135.1
2012  16 23   6.0  459. 154   -10 135.1
2012  17  0   4.9  476. 141   -14 134.5
2012  17  1   4.6  460. 141   -20 134.5
2012  17  2   4.1  467. 141   -17 134.5
2012  17  3   3.7  469. 141   -13 134.5
2012  17  4   3.3  472. 141   -12 134.5
2012  17  5   2.7  472. 141    -8 134.5
2012  17  6   3.5  459. 141    -6 134.5
2012  17  7   3.9  459. 141    -6 134.5
2012  17  8   4.1  463. 141    -7 134.5
2012  17  9   4.1  443. 141   -10 134.5
2012  17 10   4.1  446. 141   -14 134.5
2012  17 11   4.1  442. 141   -13 134.5
2012  17 12   3.6  436. 141   -10 134.5
2012  17 13   3.6  433. 141    -6 134.5
2012  17 14   4.2  421. 141    -1 134.5
2012  17 15   3.7  416. 141    -2 134.5
2012  17 16   4.2  410. 141    -1 134.5
2012  17 17   4.6  396. 141    -1 134.5
2012  17 18   4.5  398. 141    -2 134.5
2012  17 19   4.4  397. 141    -6 134.5
2012  17 20   4.5  396. 141    -8 134.5
2012  17 21   3.5  411. 141    -5 134.5
2012  17 22   3.9  425. 141    -5 134.5
2012  17 23   4.7  418. 141    -6 134.5
2012  18  0   4.6  400. 126    -7 143.4
2012  18  1   4.5  413. 126    -3 143.4
2012  18  2   4.4  418. 126     2 143.4
2012  18  3   4.2  420. 126     2 143.4
2012  18  4   4.0  401. 126    -2 143.4
2012  18  5   3.8  399. 126    -1 143.4
2012  18  6   3.5  388. 126    -1 143.4
2012  18  7   4.4  393. 126    -2 143.4
2012  18  8   4.7  405. 126    -3 143.4
2012  18  9   4.8  409. 126    -4 143.4
2012  18 10   4.9  409. 126    -3 143.4
2012  18 11   5.0  411. 126    -5 143.4
2012  18 12   5.1  405. 126    -5 143.4
2012  18 13   5.2  403. 126    -6 143.4
2012  18 14   5.1  394. 126    -4 143.4
2012  18 15   5.0  391. 126    -5 143.4
2012  18 16   4.6  387. 126    -4 143.4
2012  18 17   4.7  376. 126    -2 143.4
2012  18 18   4.7  381. 126    -1 143.4
2012  18 19   4.5  382. 126    -2 143.4
2012  18 20   4.9  386. 126    -5 143.4
2012  18 21   4.8  375. 126    -5 143.4
2012  18 22   4.7  385. 126    -6 143.4
2012  18 23   4.7  381. 126    -5 143.4
2012  19  0   4.3  372. 105    -3 152.0
2012  19  1   4.2  361. 105    -4 152.0
2012  19  2   4.0  360. 105    -5 152.0
2012  19  3   3.9  362. 105    -4 152.0
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Mon, Jun 17, 2024 at 7:50 AM Jibrin Alhassan <jibrin.alhassan using unn.edu.ng>
wrote:

> 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   SSN    Dst 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 <ruipbarradas using sapo.pt> 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
>> > year    month    day   hour
>> > 2012   08         01     01
>> > 2012   08         01     02
>> > 2012   08        01      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 <ruipbarradas using sapo.pt>
>> 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   SSN    Dst 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  ssn    Dst 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 using 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   SSN    Dst 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
>> >>
>> >
>> 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
>>
>>
>>
>> --
>> Este e-mail foi analisado pelo software antivírus AVG para verificar a
>> presença de vírus.
>> www.avg.com
>>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list