Sorry for unclear title. I have data like this;
date pr
1 12-24-2019 1.21
2 12-25-2019 0.00
3 12-26-2019 0.00
4 12-27-2019 1.46
5 12-28-2019 0.00
6 12-29-2019 0.00
But I want to convert it to this type;
year month date time pr
1 2019 12 24 1 1.21
2 2019 12 25 1 0.00
3 2019 12 26 1 0.00
4 2019 12 27 1 1.46
5 2019 12 28 1 0.00
6 2019 12 29 1 0.00
Here is structure of my data;
data<-structure(list(date = c("12-24-2019", "12-25-2019", "12-26-2019",
"12-27-2019", "12-28-2019", "12-29-2019"), pr = c(1.21, 0, 0,
1.46, 0, 0)), row.names = c(NA, 6L), class = "data.frame")
And the desired output;
out<-structure(list(year = c(2019L, 2019L, 2019L, 2019L, 2019L, 2019L
), month = c(12L, 12L, 12L, 12L, 12L, 12L), date = c(24L, 25L, 26L, 27L,
28L, 29L), time = c(1L, 1L, 1L, 1L, 1L, 1L), pr = c(1.21, 0, 0,
1.46, 0, 0)), row.names = c("1", "2", "3", "4", "5",
"6"), class = "data.frame")
Time will be fixed as 1.