Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert julian day to day/month/year

Tags:

r

julian-date

My post was apparently unclear, so I'm trying to fix it, don't hesitate to tell me if I'm still unclear!

I got a dataframe of physical variables, with a data every minute. I'd like to convert the 4 first columns into a single one: "%d/%m/%Y %H:%M" (GMT) in R.

Year    Julian_day  Hour    Minute  Air_temp    Water_temp  Rel_hum   Wind_int  Wind_dir
2012    1   0   0   11.82   4.73    87.2    5.1 310
2012    1   0   1   11.92   4.743   87.2    5   310
2012    1   0   2   11.86   4.748   86.9    4.7 310
like image 930
Doc Martin's Avatar asked Jul 30 '13 13:07

Doc Martin's


1 Answers

# This imports your data into a variable named "weather"
weather <- read.table(text = "Year    Julian_day  Hour    Minute  Air_temp    Water_temp  Rel_hum   Wind_int  Wind_dir
2012    1   0   0   11.82   4.73    87.2    5.1 310
2012    1   0   1   11.92   4.743   87.2    5   310
2012    1   0   2   11.86   4.748   86.9    4.7 310", header = TRUE)

# Combine the first four columns into a character vector
date_info <- with(weather, paste(Year, Julian_day, Hour, Minute))
# Parse that character vector
strptime(date_info, "%Y %j %H %M")
like image 58
Richie Cotton Avatar answered Sep 30 '22 09:09

Richie Cotton