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

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

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

2024-06-17 Thread Rui Barradas
Às 09:44 de 17/06/2024, Jibrin Alhassan escreveu: Hello Rui, The df1 output printed from June instead of January .Here is part of it. 4288 2012-06-27 15 6.2 420 70 -7 109.9 4289 2012-06-27 16 6.5 442 70 -9 109.9 4290 2012-06-27 17 6.3 450 70 -6 109.9 4291 2012-06-27 18 6.0

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

2024-06-17 Thread Jibrin Alhassan
Hello Rui, The df1 output printed from June instead of January .Here is part of it. 4288 2012-06-27 15 6.2 420 70 -7 109.9 4289 2012-06-27 16 6.5 442 70 -9 109.9 4290 2012-06-27 17 6.3 450 70 -6 109.9 4291 2012-06-27 18 6.0 453 700 109.9 4292 2012-06-27 19 6.7 473 70

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

2024-06-17 Thread Rui Barradas
Às 09:12 de 17/06/2024, Jibrin Alhassan escreveu: Hello Rui, Here is the head(df1) output Date HR IMF SWS SSN Dst f10.7 1 2012-01-01 0 4.0 379 71 -8 999.9 2 2012-01-01 1 4.4 386 71 -3 999.9 3 2012-01-01 2 4.8 380 71 -4 999.9 4 2012-01-01 3 5.4 374 71 -5 999.9 5 2012-01-01 4 4.5 369

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

2024-06-17 Thread Jibrin Alhassan
Hello Rui, Here is the head(df1) output Date HR IMF SWS SSN Dst f10.7 1 2012-01-01 0 4.0 379 71 -8 999.9 2 2012-01-01 1 4.4 386 71 -3 999.9 3 2012-01-01 2 4.8 380 71 -4 999.9 4 2012-01-01 3 5.4 374 71 -5 999.9 5 2012-01-01 4 4.5 369 71 -9 999.9 6 2012-01-01 5 4.2 368 71 -7 999.9

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

2024-06-17 Thread Rui Barradas
Às 07:53 de 17/06/2024, Jibrin Alhassan escreveu: Part of it is pasted below YEAR DOY HRIMF SWS SSN Dst f10.7 2012 1 0 4.0 379. 71-8 999.9 2012 1 1 4.4 386. 71-3 999.9 2012 1 2 4.8 380. 71-4 999.9 2012 1 3 5.4 374. 71-5 999.9 2012 1 4 4.5

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

2024-06-17 Thread Jibrin Alhassan
Part of it is pasted below YEAR DOY HRIMF SWS SSN Dst f10.7 2012 1 0 4.0 379. 71-8 999.9 2012 1 1 4.4 386. 71-3 999.9 2012 1 2 4.8 380. 71-4 999.9 2012 1 3 5.4 374. 71-5 999.9 2012 1 4 4.5 369. 71-9 999.9 2012 1 5 4.2 368. 71

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

2024-06-17 Thread Jibrin Alhassan
Hello Rui, Your patience is indeed amazing. Your script tested as shown below worked perfectly well. df1 <- read.table(text = "YEAR DOY HR IMF SW SSNDst f10.7 2012 215 4 5.1 371. 143-4 138.6 ", header = TRUE) with(df1, paste(YEAR, DOY)) |> as.Date(format = "%Y %j") df1$Date <-

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

2024-06-16 Thread Rolf Turner
On Sun, 16 Jun 2024 08:33:03 +0100 Rui Barradas wrote: > Hello, > > There is an error in your new code: > > > paste YEAR with DOY, not with HR. > > > As for the rest, is your real data like the one you posted before? > If it is then I don't see anything wrong with my (tested) solution.

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

2024-06-16 Thread Rui Barradas
Às 21:42 de 15/06/2024, Jibrin Alhassan escreveu: Thank you Rui. I ran the following script df1 <- read.table("solar_hour", header = TRUE) df1$date <- as.Date(paste(df1$year, df1$hour), format = "%Y %j", origin = "2012-08-01-0") df2 <- df1[c("date", "IMF", "SWS", "SSN", "Dst", "f10")]

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

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

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

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

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

2024-06-15 Thread Ebert,Timothy Aaron
- df_date2[ , -c(2, 9, 10)] # Reorganize columns to desired locations df_date2 <- df_date2[, c("YEAR", "M", "D", "IMF", "SW", "SSN", "Dst", "f10.7")] # Rename "Year" to "Y" names(df_date2)[names(

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

2024-06-15 Thread Rui Barradas
Às 20:00 de 15/06/2024, Jibrin Alhassan escreveu: I have solar-geophysical data e.g as blow: YEAR DOY HR IMF SW SSNDst f10.7 2012 214 0 3.4 403. 132-9 154.6 2012 214 1 3.7 388. 132 -10 154.6 2012 214 2 3.7 383. 132 -10 154.6 2012 214 3 3.7 391. 132-9 154.6

[R] code for year month day hr format

2024-06-15 Thread Jibrin Alhassan
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