Hello,
I am running a series of linear regressions between time and some quantitative trait. In order to do so, I need to convert date to some numeric value.
I have tried the following:
anna$date <- as.POSIXct(anna$date, origin="1861.11.20", format="%Y.%m.%d")
But when I try cor.test, I get the error 'x is not a numeric vector.
The following is my previous code up to this point:
anna <- as.data.frame(read.csv("Anna_total.csv", header=T))
anna$date <- as.POSIXct(anna$date, origin="1861.11.20", format="%Y.%m.%d")
###Note: I have also tried POSIXlt
ml <- filter(anna, sex == "M")
male_length <- ml[!is.na(ml$length),]
cor.test(male_length$date, male_length$length)
Any help that would allow me to run a regression between time and a trait would be very helpful.
Thank you so much! This is perfect.