I am looking to produce a simple line graph for which I have behavioral count data for two treatment groups over multiple days and time intervals (every 2 min for 1 hr, starting at 30 sec). I have provided the first and last 10 lines but these data actually continue to 28-03-20 and were collected every other day (i.e., 14-03-20, 16-03-20, 18-03-20... 28-03-20).
Using the code below, I have been able to produce the following figure using ggplot. The answer to fix the issue seems straightforward--likely some sort of issue with the date_time column being treated as a factor or something? I am just looking to have a line graph with points at each time interval that spans the 14 day study period.
ggplot figure to visualize the issue: https://github.com/blhodinka/RHelp/issues/1#issue-676508850
Any help would be appreciated, thank you!
> zf.behav$date_time = dmy_hms(paste(zf.behav$Date, zf.behav$Time))
> head(zf.behav, n = 10L)
Date Day Time Sex Treatment Perched Ground Feed Water date_time
1 14-03-20 0 0:00:30 M CTRL 4 1 0 1 2020-03-14 00:00:30
2 14-03-20 0 0:00:30 M WT 2 3 0 0 2020-03-14 00:00:30
3 14-03-20 0 0:02:30 M CTRL 1 4 0 0 2020-03-14 00:02:30
4 14-03-20 0 0:02:30 M WT 1 4 0 0 2020-03-14 00:02:30
5 14-03-20 0 0:04:30 M CTRL 3 2 0 0 2020-03-14 00:04:30
6 14-03-20 0 0:04:30 M WT 1 4 0 0 2020-03-14 00:04:30
7 14-03-20 0 0:06:30 M CTRL 2 3 0 0 2020-03-14 00:06:30
8 14-03-20 0 0:06:30 M WT 3 2 0 0 2020-03-14 00:06:30
9 14-03-20 0 0:08:30 M CTRL 1 4 0 0 2020-03-14 00:08:30
10 14-03-20 0 0:08:30 M WT 1 4 0 0 2020-03-14 00:08:30
> tail(zf.behav, n = 10L)
Date Day Time Sex Treatment Perched Ground Feed Water date_time
951 28-03-20 14 0:50:30 F CTRL 2 3 0 0 2020-03-28 00:50:30
952 28-03-20 14 0:50:30 F WT 5 0 0 2 2020-03-28 00:50:30
953 28-03-20 14 0:52:30 F CTRL 5 0 0 1 2020-03-28 00:52:30
954 28-03-20 14 0:52:30 F WT 2 3 0 0 2020-03-28 00:52:30
955 28-03-20 14 0:54:30 F CTRL 3 2 0 0 2020-03-28 00:54:30
956 28-03-20 14 0:54:30 F WT 1 4 0 0 2020-03-28 00:54:30
957 28-03-20 14 0:56:30 F CTRL 4 1 0 0 2020-03-28 00:56:30
958 28-03-20 14 0:56:30 F WT 1 4 0 0 2020-03-28 00:56:30
959 28-03-20 14 0:58:30 F CTRL 3 2 0 0 2020-03-28 00:58:30
960 28-03-20 14 0:58:30 F WT 3 2 0 0 2020-03-28 00:58:30
> ggplot(zf.behav, aes(date_time, Perched, color=Treatment)) +
geom_line() +
scale_x_datetime(breaks = "2 days")