My dataset looks like this:
> head(GLM_df)
# A tibble: 6 x 9
# Groups: hour [6]
hour Feeding Foraging Standing ID Area Feeding_Foraging Feeding_Standing Standing_Foraging
<int> <dbl> <dbl> <dbl> <chr> <chr> <dbl> <dbl> <dbl>
1 0 3.5 23.3 1 41361 Seronera 26.8 4.5 24.3
2 1 2.71 24.2 1 41361 Seronera 26.9 3.71 25.2
3 2 2.5 24.3 2 41361 Seronera 26.8 4.5 26.3
4 3 6.88 18.7 3.89 41361 Seronera 25.5 10.8 22.6
5 4 7.5 17.6 3.67 41361 Seronera 25.1 11.2 21.3
6 5 7.22 19.6 2.45 41361 Seronera 26.8 9.67 22.1
And I simply would like to add a column Day_Night, which will have Day for a value in GLM_df$hour between 6 and 18 or will have Night otherwise.
I tried using the expression below but I'm getting the following error:
> GLM_df$Day_Night<-ifelse(GLM_df$hour==(6:18),Day,Night)
Error in ifelse(GLM_df$hour == (6:18), Day, Night) :
object 'Day' not found
In addition: Warning message:
In GLM_df$hour == (6:18) :
longer object length is not a multiple of shorter object length
Any help is appreciated!
Aucun commentaire:
Enregistrer un commentaire