[R] PROBLEM RESOLED::code for year month day hr format
The help I sought on code for year month day and hr format for solar wind hourly data has been resolved. Thank you all for your time, patience and wonderful contributions. Jibrin Alhassan. On Mon, Jun 17, 2024, 9:26 PM Jibrin Alhassan wrote: > 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
Re: [R] code for year month day hr format
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
Re: [R] code for year month day hr format
5.5 527 110 -25 167.1 4620 2012-07-11 11 6.0 527 110 -22 167.1 4621 2012-07-11 12 5.8 518 110 -22 167.1 4622 2012-07-11 13 5.4 515 110 -19 167.1 4623 2012-07-11 14 5.3 513 110 -21 167.1 4624 2012-07-11 15 5.5 512 110 -21 167.1 4625 2012-07-11 16 5.2 505 110 -21 167.1 4626 2012-07-11 17 4.9 512 110 -18 167.1 4627 2012-07-11 18 5.1 514 110 -17 167.1 4628 2012-07-11 19 6.2 520 110 -13 167.1 4629 2012-07-11 20 6.6 510 110 -17 167.1 4630 2012-07-11 21 6.2 516 110 -18 167.1 4631 2012-07-11 22 5.8 512 110 -24 167.1 4632 2012-07-11 23 5.9 509 110 -31 167.1 4633 2012-07-12 0 6.1 502 125 -34 170.9 4634 2012-07-12 1 6.6 506 125 -34 170.9 4635 2012-07-12 2 6.1 502 125 -22 170.9 4636 2012-07-12 3 5.8 480 125 -18 170.9 4637 2012-07-12 4 5.7 474 125 -15 170.9 4638 2012-07-12 5 5.4 474 125 -23 170.9 4639 2012-07-12 6 6.1 466 125 -28 170.9 4640 2012-07-12 7 5.4 460 125 -32 170.9 4641 2012-07-12 8 4.8 453 125 -32 170.9 4642 2012-07-12 9 4.7 445 125 -28 170.9 4643 2012-07-12 10 4.9 436 125 -29 170.9 4644 2012-07-12 11 4.9 441 125 -23 170.9 4645 2012-07-12 12 4.9 440 125 -18 170.9 4646 2012-07-12 13 4.2 417 125 -15 170.9 4647 2012-07-12 14 3.5 414 125 -16 170.9 4648 2012-07-12 15 3.9 418 125 -14 170.9 4649 2012-07-12 16 4.2 419 125 -11 170.9 4650 2012-07-12 17 3.9 416 125 -11 170.9 4651 2012-07-12 18 4.0 416 125 -12 170.9 4652 2012-07-12 19 3.8 415 125 -13 170.9 4653 2012-07-12 20 3.9 410 125 -16 170.9 4654 2012-07-12 21 3.8 402 125 -20 170.9 4655 2012-07-12 22 3.8 395 125 -19 170.9 4656 2012-07-12 23 3.9 394 125 -19 170.9 4657 2012-07-13 0 3.9 395 129 -20 152.1 4658 2012-07-13 1 3.8 395 129 -19 152.1 4659 2012-07-13 2 3.8 391 129 -17 152.1 4660 2012-07-13 3 3.8 385 129 -16 152.1 4661 2012-07-13 4 3.7 376 129 -15 152.1 4662 2012-07-13 5 3.8 371 129 -15 152.1 4663 2012-07-13 6 3.8 365 129 -14 152.1 4664 2012-07-13 7 3.9 357 129 -15 152.1 4665 2012-07-13 8 4.0 354 129 -18 152.1 4666 2012-07-13 9 3.9 355 129 -20 152.1 4667 2012-07-13 10 3.9 353 129 -19 152.1 4668 2012-07-13 11 3.7 357 129 -18 152.1 4669 2012-07-13 12 3.8 357 129 -18 152.1 4670 2012-07-13 13 3.8 355 129 -18 152.1 4671 2012-07-13 14 3.7 347 129 -17 152.1 4672 2012-07-13 15 3.7 350 129 -15 152.1 4673 2012-07-13 16 3.7 346 129 -13 152.1 4674 2012-07-13 17 3.7 341 129 -10 152.1 4675 2012-07-13 18 3.3 340 129 -8 152.1 4676 2012-07-13 19 3.2 338 129 -9 152.1 4677 2012-07-13 20 3.3 333 129 -10 152.1 4678 2012-07-13 21 3.4 329 129 -9 152.1 4679 2012-07-13 22 3.9 326 129 -7 152.1 4680 2012-07-13 23 4.0 324 129 -8 152.1 4681 2012-07-14 0 4.0 324 125 -9 152.8 4682 2012-07-14 1 4.0 325 125 -9 152.8 4683 2012-07-14 2 3.9 329 125 -7 152.8 4684 2012-07-14 3 4.1 326 125 -5 152.8 4685 2012-07-14 4 4.4 325 125 -6 152.8 4686 2012-07-14 5 4.5 323 125 -5 152.8 4687 2012-07-14 6 5.0 319 125 -5 152.8 4688 2012-07-14 7 5.2 317 125 -8 152.8 4689 2012-07-14 8 5.4 323 125 -7 152.8 4690 2012-07-14 9 5.4 318 125 -6 152.8 4691 2012-07-14 10 5.2 316 125 -8 152.8 4692 2012-07-14 11 5.2 326 125 -5 152.8 4693 2012-07-14 12 4.6 335 125 -5 152.8 4694 2012-07-14 13 4.2 340 125 -5 152.8 4695 2012-07-14 14 5.0 350 125 -5 152.8 4696 2012-07-14 15 4.9 366 125 -1 152.8 4697 2012-07-14 16 3.9 355 125 -5 152.8 4698 2012-07-14 17 5.1 369 125 -5 152.8 4699 2012-07-14 18 11.0 419 125 15 152.8 4700 2012-07-14 19 14.6 574 1254 152.8 4701 2012-07-14 20 11.2 569 125 -7 152.8 4702 2012-07-14 21 13.9 568 125 -5 152.8 4703 2012-07-14 22 15.3 574 1251 152.8 4704 2012-07-14 23 19.2 644 125 -2 152.8 4705 2012-07-15 0 11.4 665 1179 145.1 4706 2012-07-15 1 9.7 657 1170 145.1 *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Mon, Jun 17, 2024 at 9:23 AM Rui Barradas wrote: > À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.
Re: [R] code for year month day hr format
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.
Re: [R] code for year month day hr format
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 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 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 >> w
Re: [R] code for year month day hr format
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:
Re: [R] code for year month day hr format
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
[R] code for year month day hr format
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.
Re: [R] Help
Hi Kimmo, The code you sent has worked for me. Thank you very much. *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Mon, Feb 5, 2024 at 7:40 AM Kimmo Elo wrote: > Hi, > > the command line with 'text' should be: > > text(-8,-8, expression(R^2 * " = 0.62, r = 0.79, N = 161"), cex = 2 ) > > Best, > > Kimmo > > su, 2024-02-04 kello 17:16 +0100, Jibrin Alhassan kirjoitti: > > Here is the script I used to plot the graph indicating the text I > > wanted to > > insert. The line in the script that I have issues with is: text(-8,- > > 8, > > "R^2= 0.62", r = 0.79, N = 161", cex = 2 > > R^2= 0.62 is not producing R squared = 0.62. > > Thanks. > > Sys.setenv( TZ="GMT" ) > > dt <- read.table("CLMXAPTY_sim", col.names = c("FDcli", "FDapt")) > > FDcli=dt$FDcli > > FDapt=dt$FDapt > > setEPS() > > postscript(file = "cliapt2.eps") > > par(mar = c(4.3, 4.3, 1.3, 1.3), oma = c(1, 1, 1 , 1)) > > plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, cex.main > > = 0.8, > > font.lab = 1.7, font.axis = 1.7, col = "red",main = "Simultaneous > > Events > > at CLMX and APTY",ylab="CLMX",xlab="APTY") > > text(-8,-8, "R^2= 0.62", r = 0.79, N = 161", cex = 2 ) > > abline(lm(FDcli ~ FDapt, col="black")) > > dev.off() > > *Jibrin Adejoh Alhassan (Ph.D)* > > Department of Physics and Astronomy, > > University of Nigeria, Nsukka > > > > > > On Sun, Feb 4, 2024 at 5:03 PM Jibrin Alhassan > > > > wrote: > > > > > Hi Elo, > > > It gave this error message: > > > CR_plot2.R:14:37: unexpected string constant > > > 13: plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, > > > cex.main = > > > 0.8, font.lab = 1.7, font.axis = 1.7, col = "red",main = > > > "Simultaneous > > > Events at CLMX and APTY",ylab="CLMX",xlab="APTY") > > > 14: text(-8,-8, "expression(R^2*"= 0.62"), r = 0.79, N = 161" > > > ^ > > > *Jibrin Adejoh Alhassan (Ph.D)* > > > Department of Physics and Astronomy, > > > University of Nigeria, Nsukka > > > > > > > > > On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan > > > > > > wrote: > > > > > > > Thank you Zhao for the code. When I replotted the graph after > > > > inserting > > > > the code in my script, it gave me this error message without > > > > plotting the > > > > graph: > > > > Warning message: > > > > In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) > > > > : > > > > extra argument ‘col’ will be disregarded. > > > > My regards. > > > > *Jibrin Adejoh Alhassan (Ph.D)* > > > > Department of Physics and Astronomy, > > > > University of Nigeria, Nsukka > > > > > > > > > > > > On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao > > > > wrote: > > > > > > > > > ?plotmath > > > > > > > > > > expression(R^2==0.62) > > > > > > > > > > On 2024/2/4 18:10, Jibrin Alhassan wrote: > > > > > > I have done a scatter plot in R. I want to insert the > > > > > > coefficient of > > > > > > determination R^2 = 0.62 as a text in the plot. I have tried > > > > > > to write > > > > > R^2 > > > > > > but could not produce R2. I would appreciate it if someone > > > > > > could help > > > > > me > > > > > > with the syntax. I have tried: expression(paste("", R^2,"=", > > > > > > 0.62)), > > > > > but > > > > > > it did not produce R squared, rather it gave me error > > > > > > messages. Thanks. > > > > > > Jibrin Alhassan > > > > > > *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 UN
Re: [R] Help
Many thanks. On Mon, Feb 5, 2024, 1:06 AM Rolf Turner wrote: > > Please see fortunes::fortune(285). > > 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 > [[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.
Re: [R] Help
Here is the script I used to plot the graph indicating the text I wanted to insert. The line in the script that I have issues with is: text(-8,-8, "R^2= 0.62", r = 0.79, N = 161", cex = 2 R^2= 0.62 is not producing R squared = 0.62. Thanks. Sys.setenv( TZ="GMT" ) dt <- read.table("CLMXAPTY_sim", col.names = c("FDcli", "FDapt")) FDcli=dt$FDcli FDapt=dt$FDapt setEPS() postscript(file = "cliapt2.eps") par(mar = c(4.3, 4.3, 1.3, 1.3), oma = c(1, 1, 1 , 1)) plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, cex.main = 0.8, font.lab = 1.7, font.axis = 1.7, col = "red",main = "Simultaneous Events at CLMX and APTY",ylab="CLMX",xlab="APTY") text(-8,-8, "R^2= 0.62", r = 0.79, N = 161", cex = 2 ) abline(lm(FDcli ~ FDapt, col="black")) dev.off() *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Sun, Feb 4, 2024 at 5:03 PM Jibrin Alhassan wrote: > Hi Elo, > It gave this error message: > CR_plot2.R:14:37: unexpected string constant > 13: plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, cex.main = > 0.8, font.lab = 1.7, font.axis = 1.7, col = "red",main = "Simultaneous > Events at CLMX and APTY",ylab="CLMX",xlab="APTY") > 14: text(-8,-8, "expression(R^2*"= 0.62"), r = 0.79, N = 161" > ^ > *Jibrin Adejoh Alhassan (Ph.D)* > Department of Physics and Astronomy, > University of Nigeria, Nsukka > > > On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan > wrote: > >> Thank you Zhao for the code. When I replotted the graph after inserting >> the code in my script, it gave me this error message without plotting the >> graph: >> Warning message: >> In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : >> extra argument ‘col’ will be disregarded. >> My regards. >> *Jibrin Adejoh Alhassan (Ph.D)* >> Department of Physics and Astronomy, >> University of Nigeria, Nsukka >> >> >> On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao wrote: >> >>> ?plotmath >>> >>> expression(R^2==0.62) >>> >>> On 2024/2/4 18:10, Jibrin Alhassan wrote: >>> > I have done a scatter plot in R. I want to insert the coefficient of >>> > determination R^2 = 0.62 as a text in the plot. I have tried to write >>> R^2 >>> > but could not produce R2. I would appreciate it if someone could help >>> me >>> > with the syntax. I have tried: expression(paste("", R^2,"=", 0.62)), >>> but >>> > it did not produce R squared, rather it gave me error messages. Thanks. >>> > Jibrin Alhassan >>> > *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. >>> >> [[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.
Re: [R] Help
Hi Elo, It gave this error message: CR_plot2.R:14:37: unexpected string constant 13: plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, cex.main = 0.8, font.lab = 1.7, font.axis = 1.7, col = "red",main = "Simultaneous Events at CLMX and APTY",ylab="CLMX",xlab="APTY") 14: text(-8,-8, "expression(R^2*"= 0.62"), r = 0.79, N = 161" ^ *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan wrote: > Thank you Zhao for the code. When I replotted the graph after inserting > the code in my script, it gave me this error message without plotting the > graph: > Warning message: > In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : > extra argument ‘col’ will be disregarded. > My regards. > *Jibrin Adejoh Alhassan (Ph.D)* > Department of Physics and Astronomy, > University of Nigeria, Nsukka > > > On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao wrote: > >> ?plotmath >> >> expression(R^2==0.62) >> >> On 2024/2/4 18:10, Jibrin Alhassan wrote: >> > I have done a scatter plot in R. I want to insert the coefficient of >> > determination R^2 = 0.62 as a text in the plot. I have tried to write >> R^2 >> > but could not produce R2. I would appreciate it if someone could help me >> > with the syntax. I have tried: expression(paste("", R^2,"=", 0.62)), >> but >> > it did not produce R squared, rather it gave me error messages. Thanks. >> > Jibrin Alhassan >> > *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. >> > [[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.
Re: [R] Help
Thank you Zhao for the code. When I replotted the graph after inserting the code in my script, it gave me this error message without plotting the graph: Warning message: In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : extra argument ‘col’ will be disregarded. My regards. *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao wrote: > ?plotmath > > expression(R^2==0.62) > > On 2024/2/4 18:10, Jibrin Alhassan wrote: > > I have done a scatter plot in R. I want to insert the coefficient of > > determination R^2 = 0.62 as a text in the plot. I have tried to write R^2 > > but could not produce R2. I would appreciate it if someone could help me > > with the syntax. I have tried: expression(paste("", R^2,"=", 0.62)), but > > it did not produce R squared, rather it gave me error messages. Thanks. > > Jibrin Alhassan > > *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. > [[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
I have done a scatter plot in R. I want to insert the coefficient of determination R^2 = 0.62 as a text in the plot. I have tried to write R^2 but could not produce R2. I would appreciate it if someone could help me with the syntax. I have tried: expression(paste("", R^2,"=", 0.62)), but it did not produce R squared, rather it gave me error messages. Thanks. Jibrin Alhassan *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.
Re: [R] Plotting world maps with locations.
Hello Romanus, You are to post only the code and the error messages and not all the information from your terminal in R session. On Fri, Feb 12, 2021, 4:35 PM Romanus Ejike wrote: > Please, I need help from anyone that can solve this problem. > I wanted to plot a world map with locations and names of the locations but > could not. The codes I have tried are as shown below. > ugwoke@ugwoke-HP-ENVY-Laptop-13-aq0xxx:~/Desktop$ R > > R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out" > Copyright (C) 2020 The R Foundation for Statistical Computing > Platform: x86_64-pc-linux-gnu (64-bit) > > R is free software and comes with ABSOLUTELY NO WARRANTY. > You are welcome to redistribute it under certain conditions. > Type 'license()' or 'licence()' for distribution details. > > Natural language support but running in an English locale > > R is a collaborative project with many contributors. > Type 'contributors()' for more information and > 'citation()' on how to cite R or R packages in publications. > > Type 'demo()' for some demos, 'help()' for on-line help, or > 'help.start()' for an HTML browser interface to help. > Type 'q()' to quit R. > > > NMdata <- > > read.table("NM1989.txt",col.names=c("SNAME","FNAME","NMTYPE","LAT","LON","ALTI")) > > library(ggplot2) > > library(sf) > Linking to GEOS 3.9.0, GDAL 3.2.0, PROJ 7.2.0 > > library(rnaturalearth) > > library(rnaturalearthdata) > > world <- ne_countries(scale = "medium", returnclass = "sf") > > ggplot(data = world) + geom_sf() + labs( x = "Longitude", y = "Latitude") > + coord_sf(xlim = c(-180.00, 180.00), ylim = c(-90.00, 90.00), expand = > FALSE) + ggtitle("World map") + points(NMdata$LON,Nmdata$LAT,col = "red", > cex = 0.01) > Error in xy.coords(x, y) : object 'Nmdata' not found > > ggplot(data = world) + geom_sf() + labs( x = "Longitude", y = "Latitude") > + coord_sf(xlim = c(-180.00, 180.00), ylim = c(-90.00, 90.00), expand = > FALSE) + ggtitle("World map") + points(NMdata$LON,NMdata$LAT,col = "red", > cex = 0.01) > Error in plot.xy(xy.coords(x, y), type = type, ...) : > plot.new has not been called yet > In addition: Warning messages: > 1: In xy.coords(x, y) : NAs introduced by coercion > 2: In xy.coords(x, y) : NAs introduced by coercion > 3: In (function (display = "", width, height, pointsize, gamma, bg, : > locale not supported by Xlib: some X ops will operate in C locale > 4: In (function (display = "", width, height, pointsize, gamma, bg, : > X cannot set locale modifiers > > ggplot(data = world) + geom_sf() + labs( x = "Longitude", y = "Latitude") > + coord_sf(xlim = c(-180.00, 180.00), ylim = c(-90.00, 90.00), expand = > FALSE) + ggtitle("World map") + points(NMdata$LON,NMdata$LAT,col = "red", > cex = 0.01, pch = 20) > Error in plot.xy(xy.coords(x, y), type = type, ...) : > plot.new has not been called yet > In addition: Warning messages: > 1: In xy.coords(x, y) : NAs introduced by coercion > 2: In xy.coords(x, y) : NAs introduced by coercion. > I have also tried the codes below but it did not show the locations. > ugwoke@ugwoke-HP-ENVY-Laptop-13-aq0xxx:~/Desktop$ R > > R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out" > Copyright (C) 2020 The R Foundation for Statistical Computing > Platform: x86_64-pc-linux-gnu (64-bit) > > R is free software and comes with ABSOLUTELY NO WARRANTY. > You are welcome to redistribute it under certain conditions. > Type 'license()' or 'licence()' for distribution details. > > Natural language support but running in an English locale > > R is a collaborative project with many contributors. > Type 'contributors()' for more information and > 'citation()' on how to cite R or R packages in publications. > > Type 'demo()' for some demos, 'help()' for on-line help, or > 'help.start()' for an HTML browser interface to help. > Type 'q()' to quit R. > > > library("ggplot2") > > library(sf) > Linking to GEOS 3.9.0, GDAL 3.2.0, PROJ 7.2.0 > > library("rnaturalearth") > > library("rnaturalearthdata") > > theme_set(theme_bw()) > > world <- ne_countries(scale = "medium", returnclass = "sf") > > class(world) > [1] "sf" "data.frame" > > ggplot(data = world) + geom_sf() + labs( x = "Longitude", y = "Latitude") > + > + + ggtitle("World map") + coord_sf(crs = "+proj=laea +lat_0=52 +lon_0=10 > +x_0=4321000 +y_0=321 +ellps=GRS80 +units=m +no_defs ") > Error in +ggtitle("World map") : invalid argument to unary operator > > ggplot(data = world) + geom_sf() + labs( x = "Longitude", y = "Latitude") > + ggtitle("World map") + coord_sf(crs = "+proj=laea + lat_0=52 + lon_0=10 + > x_0=4321000 + y_0=321 + ellps=GRS80 + units=m + no_defs ") > Warning messages: > 1: In (function (display = "", width, height, pointsize, gamma, bg, : > locale not supported by Xlib: some X ops will operate in C locale > 2: In (function (display = "", width, height, pointsize, gamma, bg, : > X cannot set locale modifiers. > I really appreciate any help rendered. Thanks > > [[alternative HTML version
[R] Problem on Converting "day of year" to "year", "month" and "day" has been solved
Dear R users, > I want to thank you all for your contributions to the problem I posted. It > has been solved. Find below the code that solved the problem. > df1 <- read.table("SWS1998_2002", header = TRUE) df1$date <- as.Date(paste(df1$year, df1$day), format = "%Y %j", origin = "1998-01-01") df2 <- df1[c("date", "Dst")] head(df2) #To display all the rows print(df2 Thanks, Jibrin Alhassan [[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] Fwd: Converting "day of year" to "year", "month" and "day"
-- Forwarded message - From: Jibrin Alhassan Date: Wed, Jan 20, 2021 at 2:18 PM Subject: Re: [R] Converting "day of year" to "year", "month" and "day" To: Rui Barradas Rui, I am grateful. All the 1826 rows have been displayed. My sincere appreciation to all for your time and inputs in solving the problem I posted. It has now been solved. Jibrin Alhassan On Wed, Jan 20, 2021 at 2:00 PM Rui Barradas wrote: > Hello, > > I'm not seeing how the code I've posted can stop you from displaying > more than 6 rows. > > The following instructions are for display only, they do not change the > dataframes. > > head(df1) > head(df2) > > > To display the entire df's, try > > print(df1) > print(df2) > > > Hope this helps, > > Rui Barradas > > Às 12:56 de 20/01/21, Jibrin Alhassan escreveu: > > Rui, > > I am very much grateful for your time and inputs. I have tried to check > > how to display all the 1,826 rows. I have not found a solution yet. > > Further help please. > > Jibrin > > > > On Mon, Jan 18, 2021 at 12:14 AM Rui Barradas > <mailto:ruipbarra...@sapo.pt>> wrote: > > > > Hello, > > > > My code didn't produce only 6 rows, it displayed only 6 rows. But all > > rows now have a date column. > > > > As for the first question, > > > > df2 <- df1[c("SWS", "date")] > > > > > > selects the columns with those names. I didn't rewrite the original > > df1, > > but if you want to, assign to df1, without creating df2. > > > > Hope this helps, > > > > Rui Barradas > > > > Às 15:12 de 17/01/21, Jibrin Alhassan escreveu: > > > Hi Barradas, > > > Thanks for your assistance. It has brought me closer to what I am > > > looking for. I tried your code as shown below: > > > > df1 <- read.table("SWSdata_1998_2002", header = TRUE) > > > > df1$date <- as.Date(paste(df1$year, df1$day),format = "%Y > > %j",origin > > > = "1998-01-01") > > > > head(df1) > > >year day Hr SWS date > > > 1 1998 1 0 344 1998-01-01 > > > 2 1998 2 0 346 1998-01-02 > > > 3 1998 3 0 356 1998-01-03 > > > 4 1998 4 0 332 1998-01-04 > > > 5 1998 5 0 302 1998-01-05 > > > 6 1998 6 0 329 1998-01-06 > > > What I need is the last two columns only (SWS, date). The first 3 > > > columns (year, day Hr should go). Your code produced only 6 > > datasets. My > > > dataset is 1,826 from 1998 to 2002. How do I generate this at > once? > > > Many many thanks for your time. I have pasted below a section of > my > > > dataset for your guidance, please. > > > Jibrin > > > year day Hr SWS > > > 1998 1 0 344. > > > 1998 2 0 346. > > > 1998 3 0 356. > > > 1998 4 0 332. > > > 1998 5 0 302. > > > 1998 6 0 329. > > > 1998 7 0 395. > > > 1998 8 0 359. > > > 1998 9 0 471. > > > 1998 10 0 392. > > > 1998 11 0 346. > > > 1998 12 0 387. > > > 1998 13 0 393. > > > 1998 14 0 367. > > > 1998 15 0 320. > > > 1998 16 0 309. > > > 1998 17 0 341. > > > 1998 18 0 329. > > > 1998 19 0 322. > > > 1998 20 0 429. > > > 1998 21 0 433. > > > 1998 22 0 398. > > > 1998 23 0 393. > > > 1998 24 0 393. > > > 1998 25 0 423. > > > 1998 26 0 426. > > > 1998 27 0 429. > > > 1998 28 0 386. > > > 1998 29 0 381. > > > 1998 30 0 375. > > > 1998 31 0 365. > > > 1998 32 0 450. > > > 1998 33 0 381. > > > 1998 34 0 316. > > > 1998 35 0 351. > > > 1998 36 0 306. > > > 1998 37 0 312. > > > 1998 38 0 320. > > > 1998 39 0 339. > > > 1998 40 0 395. > > > 1998 41 0 429. > > > 1998 42 0 479. > > > 1998 43 0 495. > > > 1998 44 0 407. > > > 1998 45 0 358. > > > 1998 46 0 360. > >
Re: [R] Converting "day of year" to "year", "month" and "day"
Jeff, Thank you so much for the challenge. It is inspiring. Jibrin On Sun, Jan 17, 2021 at 7:04 PM Jeff Newmiller wrote: > This is an opportunity for you to think for yourself (r-help) instead of > expecting solutions neatly wrapped and delivered (r-do-my-work-for-me). > Remove the no-longer-needed columns once the desired columns are available. > > On January 17, 2021 7:12:28 AM PST, Jibrin Alhassan < > jibrin.alhas...@unn.edu.ng> wrote: > >Hi Barradas, > >Thanks for your assistance. It has brought me closer to what I am > >looking > >for. I tried your code as shown below: > >> df1 <- read.table("SWSdata_1998_2002", header = TRUE) > >> df1$date <- as.Date(paste(df1$year, df1$day),format = "%Y %j",origin > >= > >"1998-01-01") > >> head(df1) > > year day Hr SWS date > >1 1998 1 0 344 1998-01-01 > >2 1998 2 0 346 1998-01-02 > >3 1998 3 0 356 1998-01-03 > >4 1998 4 0 332 1998-01-04 > >5 1998 5 0 302 1998-01-05 > >6 1998 6 0 329 1998-01-06 > >What I need is the last two columns only (SWS, date). The first 3 > >columns > >(year, day Hr should go). Your code produced only 6 datasets. My > >dataset is > >1,826 from 1998 to 2002. How do I generate this at once? > >Many many thanks for your time. I have pasted below a section of my > >dataset > >for your guidance, please. > >Jibrin > >year day Hr SWS > >1998 1 0 344. > >1998 2 0 346. > >1998 3 0 356. > >1998 4 0 332. > >1998 5 0 302. > >1998 6 0 329. > >1998 7 0 395. > >1998 8 0 359. > >1998 9 0 471. > >1998 10 0 392. > >1998 11 0 346. > >1998 12 0 387. > >1998 13 0 393. > >1998 14 0 367. > >1998 15 0 320. > >1998 16 0 309. > >1998 17 0 341. > >1998 18 0 329. > >1998 19 0 322. > >1998 20 0 429. > >1998 21 0 433. > >1998 22 0 398. > >1998 23 0 393. > >1998 24 0 393. > >1998 25 0 423. > >1998 26 0 426. > >1998 27 0 429. > >1998 28 0 386. > >1998 29 0 381. > >1998 30 0 375. > >1998 31 0 365. > >1998 32 0 450. > >1998 33 0 381. > >1998 34 0 316. > >1998 35 0 351. > >1998 36 0 306. > >1998 37 0 312. > >1998 38 0 320. > >1998 39 0 339. > >1998 40 0 395. > >1998 41 0 429. > >1998 42 0 479. > >1998 43 0 495. > >1998 44 0 407. > >1998 45 0 358. > >1998 46 0 360. > >1998 47 0 382. > >1998 48 0 394. > >1998 49 0 393. > >1998 50 0 435. > >1998 51 0 408. > >1998 52 0 360. > >1998 53 0 372. > >1998 54 0 376. > >1998 55 0 379. > >1998 56 0 361. > >1998 57 0 333. > >1998 58 0 321. > >1998 59 0 344. > >1998 60 0 412. > >1998 61 0 428. > >1998 62 0 401. > >1998 63 0 369. > >1998 64 0 343. > >1998 65 0 330. > >1998 66 0 317. > >1998 67 0 296. > >1998 68 0 282. > >1998 69 0 404. > >1998 70 0 530. > >1998 71 0 525. > >1998 72 0 484. > >1998 73 0 430. > >1998 74 0 388. > >1998 75 0 347. > >1998 76 0 337. > >1998 77 0 342. > >1998 78 0 305. > >1998 79 0 329. > >1998 80 0 420. > >1998 81 0 564. > >1998 82 0 483. > >1998 83 0 385. > >1998 84 0 393. > >1998 85 0 437. > >1998 86 0 441. > >1998 87 0 434. > >1998 88 0 471. > >1998 89 0 429. > >1998 90 0 412. > >1998 91 0 370. > >1998 92 0 326. > >1998 93 0 357. > >1998 94 0 338. > >1998 95 0 380. > >1998 96 0 339. > >1998 97 0 312. > >1998 98 0 313. > >1998 99 0 327. > >1998 100 0 362. > >1998 101 0 358. > >1998 102 0 387. > >1998 103 0 397. > >1998 104 0 375. > >1998 105 0 350. > >1998 106 0 357. > >1998 107 0 472. > >1998 108 0 526. > >1998 109 0 396. > >1998 110 0 374. > >1998 111 0 376. > >1998 112 0 355. > >1998 113 0 343. > >1998 114 0 425. > >1998 115 0 426. > >1998 116 0 479. > >1998 117 0 469. > >1998 118 0 425. > >1998 119 0 344. > >1998 120 0 341. > >1998 121 0 426. > >1998 122 0 601. > >1998 123 0 476. > >1998 124 0 670. > >1998 125 0 585. > >1998 126 0 496. > >1998 127 0 479
Re: [R] Converting "day of year" to "year", "month" and "day"
; [86] "1998-03-27" "1998-03-28" "1998-03-29" "1998-03-30" "1998-03-31" > [91] "1998-04-01" "1998-04-02" "1998-04-03" "1998-04-04" "1998-04-05" > [96] "1998-04-06" "1998-04-07" "1998-04-08" "1998-04-09" "1998-04-10" > > Or, if you want month numbers and day of month as numerics: > > > as.POSIXlt(as.Date(ISOdate(1998,1,1))+(1:100)-1)$mon > [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 > 1 1 1 > [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 > 2 2 2 > [75] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 > > as.POSIXlt(as.Date(ISOdate(1998,1,1))+(1:100)-1)$mday > [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 > 24 25 > [26] 26 27 28 29 30 31 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 > 18 19 > [51] 20 21 22 23 24 25 26 27 28 1 2 3 4 5 6 7 8 9 10 11 12 13 14 > 15 16 > [76] 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 5 6 7 > 8 9 10 > > -pd > > > On 16 Jan 2021, at 07:48 , Jibrin Alhassan > wrote: > > > > Hi Barradas > > Sorry for the delay. Below is a section of my data. I have up to 1826 > > covering 1998 to 2002 > > year day Hr SWS > > 1998 1 0 344. > > 1998 2 0 346. > > 1998 3 0 356. > > 1998 4 0 332. > > 1998 5 0 302. > > 1998 6 0 329. > > 1998 7 0 395. > > 1998 8 0 359. > > 1998 9 0 471. > > 1998 10 0 392. > > 1998 11 0 346. > > 1998 12 0 387. > > 1998 13 0 393. > > 1998 14 0 367. > > 1998 15 0 320. > > 1998 16 0 309. > > 1998 17 0 341. > > 1998 18 0 329. > > 1998 19 0 322. > > 1998 20 0 429. > > 1998 21 0 433. > > 1998 22 0 398. > > 1998 23 0 393. > > 1998 24 0 393. > > 1998 25 0 423. > > 1998 26 0 426. > > 1998 27 0 429. > > 1998 28 0 386. > > 1998 29 0 381. > > 1998 30 0 375. > > 1998 31 0 365. > > 1998 32 0 450. > > 1998 33 0 381. > > 1998 34 0 316. > > 1998 35 0 351. > > 1998 36 0 306. > > 1998 37 0 312. > > 1998 38 0 320. > > 1998 39 0 339. > > 1998 40 0 395. > > 1998 41 0 429. > > 1998 42 0 479. > > 1998 43 0 495. > > 1998 44 0 407. > > 1998 45 0 358. > > 1998 46 0 360. > > 1998 47 0 382. > > 1998 48 0 394. > > 1998 49 0 393. > > 1998 50 0 435. > > 1998 51 0 408. > > 1998 52 0 360. > > 1998 53 0 372. > > 1998 54 0 376. > > 1998 55 0 379. > > 1998 56 0 361. > > 1998 57 0 333. > > 1998 58 0 321. > > 1998 59 0 344. > > 1998 60 0 412. > > 1998 61 0 428. > > 1998 62 0 401. > > 1998 63 0 369. > > 1998 64 0 343. > > 1998 65 0 330. > > 1998 66 0 317. > > 1998 67 0 296. > > 1998 68 0 282. > > 1998 69 0 404. > > 1998 70 0 530. > > 1998 71 0 525. > > 1998 72 0 484. > > 1998 73 0 430. > > 1998 74 0 388. > > 1998 75 0 347. > > 1998 76 0 337. > > 1998 77 0 342. > > 1998 78 0 305. > > 1998 79 0 329. > > 1998 80 0 420. > > 1998 81 0 564. > > 1998 82 0 483. > > 1998 83 0 385. > > 1998 84 0 393. > > 1998 85 0 437. > > 1998 86 0 441. > > 1998 87 0 434. > > 1998 88 0 471. > > 1998 89 0 429. > > 1998 90 0 412. > > 1998 91 0 370. > > 1998 92 0 326. > > 1998 93 0 357. > > 1998 94 0 338. > > 1998 95 0 380. > > 1998 96 0 339. > > 1998 97 0 312. > > 1998 98 0 313. > > 1998 99 0 327. > > 1998 100 0 362. > > 1998 101 0 358. > > 1998 102 0 387. > > 1998 103 0 397. > > 1998 104 0 375. > > 1998 105 0 350. > > 1998 106 0 357. > > 1998 107 0 472. > > 1998 108 0 526. > > 1998 109 0 396. > > 1998 110 0 374. > > 1998 111 0 376. > > 1998 112 0 355. > > 1998 113 0 343. > > 1998 114 0 425. > > 1998 115 0 426. > > 1998 116 0 479. > > 1998 117 0 469. > > 1998 118 0 425. > > 1998 119 0 344. > > 1998 120 0 341. > > 1998 121 0 426. > > 1998 122 0 601. > > 1998 123 0 476. > > 1998 124 0 670. > > 1998 125 0 585. > > 1998 126 0 496. > > 1998 127 0 4
Re: [R] Converting "day of year" to "year", "month" and "day"
Hi Bert, Thanks for your time. I will check some relevant tutorias. I am very grateful. Jibrin Th On Fri, Jan 15, 2021 at 7:49 PM Bert Gunter wrote: > There are many good tutorials for R. As a "newbie", you need to avail > yourself of them. Although this forum is meant to "help", it is not > designed to provide tutorials. Understanding basic R functionality is > largely assumed here. > > Searching on "tutorials on date-time data in R" brought up many > possibilities. Choose one or more that best suits your needs. > > As for your specific query, you seem not to understand R's "vectorization" > behavior: your statement, "it can only convert one day of the year at a > time", is false. Again, search for a tutorial on "vectorization in R." But > note that the "Intro to R" tutorial that ships with R already has this. > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Fri, Jan 15, 2021 at 9:55 AM Jibrin Alhassan < > jibrin.alhas...@unn.edu.ng> wrote: > >> Dear R users, >> I am very new to R software. I have solar wind speed data needed for my >> work. How do I convert day in the year to year, month, and day with R >> software? I have used this code >> as.Date(0, origin = "1998-01-01") >> but it can only convert one day of the year at a time. Meanwhile, I have >> up >> to the 1998-2002 data set. Attached is my data. >> Kindly help, please. >> Jibrin Alhassan >> __ >> 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. >> > [[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.
Re: [R] Converting "day of year" to "year", "month" and "day"
Hellow Rui, The code helped. I am very grateful. Jibrin On Mon, Jan 18, 2021 at 12:14 AM Rui Barradas wrote: > Hello, > > My code didn't produce only 6 rows, it displayed only 6 rows. But all > rows now have a date column. > > As for the first question, > > df2 <- df1[c("SWS", "date")] > > > selects the columns with those names. I didn't rewrite the original df1, > but if you want to, assign to df1, without creating df2. > > Hope this helps, > > Rui Barradas > > Às 15:12 de 17/01/21, Jibrin Alhassan escreveu: > > Hi Barradas, > > Thanks for your assistance. It has brought me closer to what I am > > looking for. I tried your code as shown below: > > > df1 <- read.table("SWSdata_1998_2002", header = TRUE) > > > df1$date <- as.Date(paste(df1$year, df1$day),format = "%Y %j",origin > > = "1998-01-01") > > > head(df1) > >year day Hr SWS date > > 1 1998 1 0 344 1998-01-01 > > 2 1998 2 0 346 1998-01-02 > > 3 1998 3 0 356 1998-01-03 > > 4 1998 4 0 332 1998-01-04 > > 5 1998 5 0 302 1998-01-05 > > 6 1998 6 0 329 1998-01-06 > > What I need is the last two columns only (SWS, date). The first 3 > > columns (year, day Hr should go). Your code produced only 6 datasets. My > > dataset is 1,826 from 1998 to 2002. How do I generate this at once? > > Many many thanks for your time. I have pasted below a section of my > > dataset for your guidance, please. > > Jibrin > > year day Hr SWS > > 1998 1 0 344. > > 1998 2 0 346. > > 1998 3 0 356. > > 1998 4 0 332. > > 1998 5 0 302. > > 1998 6 0 329. > > 1998 7 0 395. > > 1998 8 0 359. > > 1998 9 0 471. > > 1998 10 0 392. > > 1998 11 0 346. > > 1998 12 0 387. > > 1998 13 0 393. > > 1998 14 0 367. > > 1998 15 0 320. > > 1998 16 0 309. > > 1998 17 0 341. > > 1998 18 0 329. > > 1998 19 0 322. > > 1998 20 0 429. > > 1998 21 0 433. > > 1998 22 0 398. > > 1998 23 0 393. > > 1998 24 0 393. > > 1998 25 0 423. > > 1998 26 0 426. > > 1998 27 0 429. > > 1998 28 0 386. > > 1998 29 0 381. > > 1998 30 0 375. > > 1998 31 0 365. > > 1998 32 0 450. > > 1998 33 0 381. > > 1998 34 0 316. > > 1998 35 0 351. > > 1998 36 0 306. > > 1998 37 0 312. > > 1998 38 0 320. > > 1998 39 0 339. > > 1998 40 0 395. > > 1998 41 0 429. > > 1998 42 0 479. > > 1998 43 0 495. > > 1998 44 0 407. > > 1998 45 0 358. > > 1998 46 0 360. > > 1998 47 0 382. > > 1998 48 0 394. > > 1998 49 0 393. > > 1998 50 0 435. > > 1998 51 0 408. > > 1998 52 0 360. > > 1998 53 0 372. > > 1998 54 0 376. > > 1998 55 0 379. > > 1998 56 0 361. > > 1998 57 0 333. > > 1998 58 0 321. > > 1998 59 0 344. > > 1998 60 0 412. > > 1998 61 0 428. > > 1998 62 0 401. > > 1998 63 0 369. > > 1998 64 0 343. > > 1998 65 0 330. > > 1998 66 0 317. > > 1998 67 0 296. > > 1998 68 0 282. > > 1998 69 0 404. > > 1998 70 0 530. > > 1998 71 0 525. > > 1998 72 0 484. > > 1998 73 0 430. > > 1998 74 0 388. > > 1998 75 0 347. > > 1998 76 0 337. > > 1998 77 0 342. > > 1998 78 0 305. > > 1998 79 0 329. > > 1998 80 0 420. > > 1998 81 0 564. > > 1998 82 0 483. > > 1998 83 0 385. > > 1998 84 0 393. > > 1998 85 0 437. > > 1998 86 0 441. > > 1998 87 0 434. > > 1998 88 0 471. > > 1998 89 0 429. > > 1998 90 0 412. > > 1998 91 0 370. > > 1998 92 0 326. > > 1998 93 0 357. > > 1998 94 0 338. > > 1998 95 0 380. > > 1998 96 0 339. > > 1998 97 0 312. > > 1998 98 0 313. > > 1998 99 0 327. > > 1998 100 0 362. > > 1998 101 0 358. > > 1998 102 0 387. > > 1998 103 0 397. > > 1998 104 0 375. > > 1998 105 0 350. > > 1998 106 0 357. > > 1998 107 0 472. > > 1998 108 0 526. > > 1998 109 0 396. > > 1998 110 0 374. > > 1998 111 0 376. > > 1998 112 0 355. > > 1998 113 0 343. > > 1998 114 0 425. > > 1998 115 0 426. > > 1998 116 0 479. > > 1998 117 0 469. > > 1998 118 0 425. > > 1998 119
Re: [R] Converting "day of year" to "year", "month" and "day"
0 0 279. 1998 231 0 312. 1998 232 0 331. 1998 233 0 298. 1998 234 0 341. 1998 235 0 493. 1998 236 0 436. 1998 237 0 400. 1998 238 0 633. 1998 239 0 630. 1998 240 0 583. 1998 241 0 547. 1998 242 0 550. 1998 243 0 499. 1998 244 0 444. 1998 245 0 427. 1998 246 0 401. On Sat, Jan 16, 2021 at 8:01 AM Rui Barradas wrote: > Hello, > > Thanks for the data, it makes things easier. > > df1 <- read.table("Jibrin_data.txt", header = TRUE) > #'data.frame': 168 obs. of 4 variables: > # $ year: int 1998 1998 1998 1998 1998 1998 1998 1998 1998 1998 ... > # $ day : int 1 2 3 4 5 6 7 8 9 10 ... > # $ Hr : int 0 0 0 0 0 0 0 0 0 0 ... > # $ SWS : num 344 346 356 332 302 329 395 359 471 392 ... > > Here is a simple way of converting the year and day of year columns to a > column of class "Date". > Like others have said, there are also CRAN packages to handle date/time > data, my favorite being package lubridate, but base R can do it. > > > df1$date <- as.Date(paste(df1$year, df1$day), > format = "%Y %j", > origin = "1998-01-01") > > head(df1) > # year day Hr SWS date > #1 1998 1 0 344 1998-01-01 > #2 1998 2 0 346 1998-01-02 > #3 1998 3 0 356 1998-01-03 > #4 1998 4 0 332 1998-01-04 > #5 1998 5 0 302 1998-01-05 > #6 1998 6 0 329 1998-01-06 > > > Hope this helps, > > Rui Barradas > > > Às 06:48 de 16/01/21, Jibrin Alhassan escreveu: > > Hi Barradas > > Sorry for the delay. Below is a section of my data. I have up to 1826 > > covering 1998 to 2002 > > year day Hr SWS > > 1998 1 0 344. > > 1998 2 0 346. > > 1998 3 0 356. > > 1998 4 0 332. > > 1998 5 0 302. > > 1998 6 0 329. > > 1998 7 0 395. > > 1998 8 0 359. > > 1998 9 0 471. > > 1998 10 0 392. > > 1998 11 0 346. > > 1998 12 0 387. > > 1998 13 0 393. > > 1998 14 0 367. > > 1998 15 0 320. > > 1998 16 0 309. > > 1998 17 0 341. > > 1998 18 0 329. > > 1998 19 0 322. > > 1998 20 0 429. > > 1998 21 0 433. > > 1998 22 0 398. > > 1998 23 0 393. > > 1998 24 0 393. > > 1998 25 0 423. > > 1998 26 0 426. > > 1998 27 0 429. > > 1998 28 0 386. > > 1998 29 0 381. > > 1998 30 0 375. > > 1998 31 0 365. > > 1998 32 0 450. > > 1998 33 0 381. > > 1998 34 0 316. > > 1998 35 0 351. > > 1998 36 0 306. > > 1998 37 0 312. > > 1998 38 0 320. > > 1998 39 0 339. > > 1998 40 0 395. > > 1998 41 0 429. > > 1998 42 0 479. > > 1998 43 0 495. > > 1998 44 0 407. > > 1998 45 0 358. > > 1998 46 0 360. > > 1998 47 0 382. > > 1998 48 0 394. > > 1998 49 0 393. > > 1998 50 0 435. > > 1998 51 0 408. > > 1998 52 0 360. > > 1998 53 0 372. > > 1998 54 0 376. > > 1998 55 0 379. > > 1998 56 0 361. > > 1998 57 0 333. > > 1998 58 0 321. > > 1998 59 0 344. > > 1998 60 0 412. > > 1998 61 0 428. > > 1998 62 0 401. > > 1998 63 0 369. > > 1998 64 0 343. > > 1998 65 0 330. > > 1998 66 0 317. > > 1998 67 0 296. > > 1998 68 0 282. > > 1998 69 0 404. > > 1998 70 0 530. > > 1998 71 0 525. > > 1998 72 0 484. > > 1998 73 0 430. > > 1998 74 0 388. > > 1998 75 0 347. > > 1998 76 0 337. > > 1998 77 0 342. > > 1998 78 0 305. > > 1998 79 0 329. > > 1998 80 0 420. > > 1998 81 0 564. > > 1998 82 0 483. > > 1998 83 0 385. > > 1998 84 0 393. > > 1998 85 0 437. > > 1998 86 0 441. > > 1998 87 0 434. > > 1998 88 0 471. > > 1998 89 0 429. > > 1998 90 0 412. > > 1998 91 0 370. > > 1998 92 0 326. > > 1998 93 0 357. > > 1998 94 0 338. > > 1998 95 0 380. > > 1998 96 0 339. > > 1998 97 0 312. > > 1998 98 0 313. > > 1998 99 0 327. > > 1998 100 0 362. > > 1998 101 0 358. > > 1998 102 0 387. > > 1998 103 0 397. > > 1998 104 0 375. > > 1998 105 0 350. > > 1998 106 0 357. > > 1998 107 0 472. > > 1998 108 0 526. > > 1998 109 0 396. > > 1998 110 0 374. > > 1998 111 0 376. > > 1998 112 0 355. > > 1998 113 0 343. > > 1998 114 0 425. > > 1998 115 0 426. > > 1998 116
Re: [R] Converting "day of year" to "year", "month" and "day"
Hi Barradas Sorry for the delay. Below is a section of my data. I have up to 1826 covering 1998 to 2002 year day Hr SWS 1998 1 0 344. 1998 2 0 346. 1998 3 0 356. 1998 4 0 332. 1998 5 0 302. 1998 6 0 329. 1998 7 0 395. 1998 8 0 359. 1998 9 0 471. 1998 10 0 392. 1998 11 0 346. 1998 12 0 387. 1998 13 0 393. 1998 14 0 367. 1998 15 0 320. 1998 16 0 309. 1998 17 0 341. 1998 18 0 329. 1998 19 0 322. 1998 20 0 429. 1998 21 0 433. 1998 22 0 398. 1998 23 0 393. 1998 24 0 393. 1998 25 0 423. 1998 26 0 426. 1998 27 0 429. 1998 28 0 386. 1998 29 0 381. 1998 30 0 375. 1998 31 0 365. 1998 32 0 450. 1998 33 0 381. 1998 34 0 316. 1998 35 0 351. 1998 36 0 306. 1998 37 0 312. 1998 38 0 320. 1998 39 0 339. 1998 40 0 395. 1998 41 0 429. 1998 42 0 479. 1998 43 0 495. 1998 44 0 407. 1998 45 0 358. 1998 46 0 360. 1998 47 0 382. 1998 48 0 394. 1998 49 0 393. 1998 50 0 435. 1998 51 0 408. 1998 52 0 360. 1998 53 0 372. 1998 54 0 376. 1998 55 0 379. 1998 56 0 361. 1998 57 0 333. 1998 58 0 321. 1998 59 0 344. 1998 60 0 412. 1998 61 0 428. 1998 62 0 401. 1998 63 0 369. 1998 64 0 343. 1998 65 0 330. 1998 66 0 317. 1998 67 0 296. 1998 68 0 282. 1998 69 0 404. 1998 70 0 530. 1998 71 0 525. 1998 72 0 484. 1998 73 0 430. 1998 74 0 388. 1998 75 0 347. 1998 76 0 337. 1998 77 0 342. 1998 78 0 305. 1998 79 0 329. 1998 80 0 420. 1998 81 0 564. 1998 82 0 483. 1998 83 0 385. 1998 84 0 393. 1998 85 0 437. 1998 86 0 441. 1998 87 0 434. 1998 88 0 471. 1998 89 0 429. 1998 90 0 412. 1998 91 0 370. 1998 92 0 326. 1998 93 0 357. 1998 94 0 338. 1998 95 0 380. 1998 96 0 339. 1998 97 0 312. 1998 98 0 313. 1998 99 0 327. 1998 100 0 362. 1998 101 0 358. 1998 102 0 387. 1998 103 0 397. 1998 104 0 375. 1998 105 0 350. 1998 106 0 357. 1998 107 0 472. 1998 108 0 526. 1998 109 0 396. 1998 110 0 374. 1998 111 0 376. 1998 112 0 355. 1998 113 0 343. 1998 114 0 425. 1998 115 0 426. 1998 116 0 479. 1998 117 0 469. 1998 118 0 425. 1998 119 0 344. 1998 120 0 341. 1998 121 0 426. 1998 122 0 601. 1998 123 0 476. 1998 124 0 670. 1998 125 0 585. 1998 126 0 496. 1998 127 0 479. 1998 128 0 569. 1998 129 0 531. 1998 130 0 489. 1998 131 0 484. 1998 132 0 480. 1998 133 0 393. 1998 134 0 332. 1998 135 0 327. 1998 136 0 493. 1998 137 0 493. 1998 138 0 430. 1998 139 0 396. 1998 140 0 408. 1998 141 0 416. 1998 142 0 376. 1998 143 0 375. 1998 144 0 415. 1998 145 0 407. 1998 146 0 398. 1998 147 0 352. 1998 148 0 349. 1998 149 0 517. 1998 150 0 597. 1998 151 0 480. 1998 152 0 435. 1998 153 0 408. 1998 154 0 441. 1998 155 0 397. 1998 156 0 374. 1998 157 0 413. 1998 158 0 582. 1998 159 0 513. 1998 160 0 459. 1998 161 0 466. 1998 162 0 414. 1998 163 0 354. 1998 164 0 341. 1998 165 0 343. 1998 166 0 369. 1998 167 0 411. 1998 168 0 355. Thanks Jibrin On Fri, Jan 15, 2021 at 7:15 PM Rui Barradas wrote: > Hello, > > No dataset was attached. Like the posting guide says, > > No binary attachments except for PS, PDF, and some image and archive > formats (others are automatically stripped off because they can contain > malicious software). Files in other formats and larger ones should > rather be put on the web and have only their URLs posted. This way a > reader has the option to download them or not. > > > Can you post sample data? Please post the output of `dput(df)`. Or, if > it is too big the output of `dput(head(df, 20))`. (`df` is the name of > your dataset.) > > Hope this helps, > > Rui Barradas > > Às 11:30 de 15/01/21, Jibrin Alhassan escreveu: > > Dear R users, > > I am very new to R software. I have solar wind speed data needed for my > > work. How do I convert day in the year to year, month, and day with R > > software? I have used this code > > as.Date(0, origin = "1998-01-01") > > but it can only convert one day of the year at a time. Meanwhile, I have > up > > to the 1998-2002 data set. Attached is my data. > > Kindly help, please. > > Jibrin Alhassan > > __ > > 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. > > > [[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] Converting "day of year" to "year", "month" and "day"
Dear R users, I am very new to R software. I have solar wind speed data needed for my work. How do I convert day in the year to year, month, and day with R software? I have used this code as.Date(0, origin = "1998-01-01") but it can only convert one day of the year at a time. Meanwhile, I have up to the 1998-2002 data set. Attached is my data. Kindly help, please. Jibrin Alhassan __ 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.