I am trying to transpose data in R. The data retrieved was a JSON file and here is an example of the dataframe I am using:
date parameter value
2020-07-01T23:50:00Z wind_dir 236.0
2020-07-01T23:40:00Z wind_dir 236.0
2020-07-01T23:40:00Z wind_speed 1.9
2020-07-01T23:30:00Z wind_dir 239.0
2020-07-01T23:10:00Z wind_dir 184.0
2020-07-01T23:00:00Z wind_dir 178.0
2020-07-01T22:50:00Z wind_speed 1.1
2020-07-01T22:50:00Z wind_dir 197.0
2020-07-01T22:40:00Z wind_speed 1.8
2020-07-01T22:30:00Z wind_speed 1.4
2020-07-01T22:20:00Z wind_dir 172.0
2020-07-01T22:20:00Z wind_speed 1.4
2020-07-01T22:00:00Z wind_dir 170.0
- I need to change the date, so it does not include T and Z.
- I want to transpose the rows and separate the parameters into two columns: wind_speed and wind_dir
The final dataset should look like:
date wind_dir wind_speed
2020-07-01 23:50:00 236.0 NA
2020-07-01 23:40:00 236.0 1.9
2020-07-01 23:30:00 239.0 NA
2020-07-01 23:10:00 184.0 NA
2020-07-01 23:00:00 178.0 NA
2020-07-01 22:50:00 197.0 1.1
2020-07-01 22:40:00 NA 1.8
2020-07-01 22:30:00 NA 1.4
2020-07-01 22:20:00 172.0 1.4
2020-07-01 22:00:00 170.0 NA
- I also would like to have the date starting with an increasing time stamp.
I appreciate your help!