This is my Dataframe: https://gofile.io/?c=7WLqCD
It looks like this:
head(testframe)
Time Station1 Station2 Station3 Station4
01.01.2017 07:00 27 38 26 25
01.01.2017 14:00 22 49 25 16
01.01.2017 21:00 41 53 46 36
02.01.2017 07:00 22 38 26 19
02.01.2017 14:00 20 54 35 13
02.01.2017 21:00 36 45 30 26
I want to calculate the mean values for Station 1 to Station 4 for every day, that means row 1-3, row 4-6, row 7-9 and so on.
class (testframe$Station1)
is factor
and I know that it has to be numeric to calculate the mean value. So I tried to convert it like this:
testframe[,4] = as.numeric(as.character(testframe$Station4))
This does not work. I have missing values that are marked as #. I replaced them with NA, but there are still problems with Station 3 and Station 4.
Also this code to calculate the mean, doesnt work. It gives me the wrong results.
colMeans(matrix(testframe$Station1, nrow=3))