I am running a function in the oce
package which generates a matrix. I transpose the matrix and then convert the matrix to a dataframe, but my POSIXct formatted date becomes a list within the date column. Here is my reproducible piece of code:
library(oce)
library(dplyr)
df <- data.frame(times = as.POSIXct(rep("2011-03-03 06:49:00", 4)),
Latitude = c(39,38,34,35),
Longitude = c(-75,-74,-73,-72),
ref = rep(T, 4))
vsunAngle = Vectorize(sunAngle)
Sun.Angle <- as.data.frame(t(with(df, vsunAngle(times, longitude = Longitude, latitude = Latitude, useRefraction = ref))))
# This is the transposition without converting to a dataframe. Not the correct time format:
t(with(df, vsunAngle(times, longitude = Longitude, latitude = Latitude, useRefraction = ref)))
How do I successfully convert this matrix to a dataframe without losing the date? I already tried extracting the column-list into a new column, but I had less luck doing this.
Thank you in advance!