Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-20 Thread Jibrin Alhassan
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-nee

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-20 Thread Jibrin Alhassan
Hello Peter, Thanks for your input. What I need runs like this. df1 <- read.table("SWSdata_1998_2002", header = TRUE) > df1$date <- as.Date(paste(df1$year, df1$day), + Error: unexpected end of input > df1$date <- as.Date(paste(df1$year, df1$day),format = "%Y %j",origin = "1998-01-01") > df2 <- df1[

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-20 Thread Jibrin Alhassan
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 > des

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-17 Thread Jibrin Alhassan
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")] > > > sel

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-17 Thread Rui Barradas
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

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-17 Thread Jeff Newmiller
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 wrote: >Hi Barradas,

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-17 Thread Jibrin Alhassan
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

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-16 Thread peter dalgaard
Something like this? > as.Date(ISOdate(1998,1,1))+(1:100)-1 [1] "1998-01-01" "1998-01-02" "1998-01-03" "1998-01-04" "1998-01-05" [6] "1998-01-06" "1998-01-07" "1998-01-08" "1998-01-09" "1998-01-10" [11] "1998-01-11" "1998-01-12" "1998-01-13" "1998-01-14" "1998-01-15" [16] "1998-01-16" "1998-

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Rui Barradas
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 ... #

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Jibrin Alhassan
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 3

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Jim Lemon
Hi Jibrin, solar_wind_sps<-data.frame(sws=306,date="2021-016") solar_wind_spd solar_wind_spd$date<-as.Date(solar_wind_spd$date,"%Y-%j") solar_wind_spd This changes the "date" field to an actual date object. If you just want to change a character string date to another format: solar_wind_spd$date<

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Martin Møller Skarbiniks Pedersen
On Fri, 15 Jan 2021 at 18:55, Jibrin Alhassan 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") Look at th

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Bill Dunlap
Use one of the POSIXt classes, POSIXct or POSIXlt, instead of the Date class. They have more methods for doing arithmetic. E.g., > dates <- as.POSIXct(tz="UTC", c("2004-03-01", "2005-03-01")) > difftime(dates, trunc(dates, units="year"), units="days") # add 1 if you want -01-01 to be day 1 in

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Bert Gunter
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 poss

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Rui Barradas
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

[R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Jibrin Alhassan
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 t