在J中将朱利安日转换为日/月/年

时间:2013-07-30 13:10:55

标签: r julian

我的帖子显然不清楚,所以我正在努力解决它,如果我还不清楚,请不要犹豫告诉我!

我得到了一个物理变量的数据框,每分钟都有一个数据。我想将4个第一列转换为单个列:R中的“%d /%m /%Y%H:%M”(GMT)。

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

感谢您的帮助!

1 个答案:

答案 0 :(得分:8)

# This imports your data into a variable named "weather"
weather <- read.table(tc <- textConnection("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); close(tc)

# 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")