Load data. Convert TIMESTAMP column from character to POSIXt.

df_mean <- read.csv(here("Data", "Camera_mean.dat"), stringsAsFactors = FALSE)
df_mean$TIMESTAMP <- df_mean$TIMESTAMP %>% as.POSIXct()

df_sd <- read.csv(here("Data", "Camera_sd.dat"), stringsAsFactors = FALSE)
df_sd$TIMESTAMP <- df_sd$TIMESTAMP %>% as.POSIXct()

df_isNA <- read.csv(here("Data", "Camera_isNA.dat"), stringsAsFactors = FALSE)
df_isNA$TIMESTAMP <- df_isNA$TIMESTAMP %>% as.POSIXct()

Tidy the data. Note that all cases of “C5P5” are converted to “C4P5” and all cases of “P9” are converted to “P8”.

For the mean and stdev calcs, filter (keep) only “Y.Disp” values. For the isNA table, separate into two tables: “sumNA” and “sumNotNA”.

df_mean1 <- df_mean %>% 
  filter(lubridate::minute(TIMESTAMP) < 10) %>% 
  gather(key = "sensor", value = "value", -TIMESTAMP) %>% 
  as.tibble() %>% 
  mutate(sensor = str_replace(sensor, "C5P5", "C4P5"),
         sensor = str_replace(sensor, "P9", "P8"), 
         cam = substring(sensor, 1, 2),
         plane = substring(sensor, 3, 4),
         target = substring(sensor, 5, nchar(sensor))) %>% 
  filter(str_detect(target, "Y.Disp") == TRUE)


df_sd1 <- df_sd %>% 
  filter(lubridate::minute(TIMESTAMP) < 10) %>% 
  gather(key = "sensor", value = "value", -TIMESTAMP) %>% 
  as.tibble() %>% 
  mutate(sensor = str_replace(sensor, "C5P5", "C4P5"),
         sensor = str_replace(sensor, "P9", "P8"), 
         cam = substring(sensor, 1, 2),
         plane = substring(sensor, 3, 4),
         target = substring(sensor, 5, nchar(sensor))) %>% 
  filter(str_detect(target, "Y.Disp") == TRUE)


df_isNA1 <- df_isNA %>% 
  filter(lubridate::minute(TIMESTAMP) < 10) %>% 
  gather(key = "sensor", value = "value", -TIMESTAMP) %>% 
  as.tibble() %>% 
  mutate(sensor = str_replace(sensor, "C5P5", "C4P5"),
         sensor = str_replace(sensor, "P9", "P8"), 
         camPlane = substring(sensor, 1, 4),
         cam = substring(sensor, 1, 2),
         plane = substring(sensor, 3, 4),
         target = substring(sensor, 5, nchar(sensor))) %>% 
  filter(str_detect(target, "sumNA")) %>% 
  arrange(plane, cam)


#2018-01-26 18:26:34
#2018-02-12 16:20:40

Plot the mean data for each plane.

myplot <- ggplot(df_mean1) +
  geom_line(aes(x=TIMESTAMP, y = value, color = sensor)) +
  ylim(c(-1, 1)) +
  xlab("") + 
  ylab("mean, inches") +
  theme(legend.title = element_blank())

loopvals <- unique(df_mean1$plane)
for (i in 1:length(loopvals)){
  print(myplot %+% subset(df_mean1, plane %in% loopvals[i]) +
          labs(title = paste0(loopvals[i], " Mean (inches)")) +
          theme(plot.title = element_text(hjust = 0.5))
  )
}

Plot the stDev data for each plane.

myplot <- ggplot(df_sd1) +
  geom_line(aes(x=TIMESTAMP, y = value, color = sensor)) +
  ylim(c(0, 0.5)) +
  xlab("") + 
  ylab("StDev, inches") +
  theme(legend.title = element_blank())

loopvals <- unique(df_sd1$plane)
for (i in 1:length(loopvals)){
  print(myplot %+% subset(df_sd1, plane %in% loopvals[i]) +
          labs(title = paste0(loopvals[i], " StDev (inches)")) +
          theme(plot.title = element_text(hjust = 0.5))
  )
}

Plot “isNA” data, facet style, for cams and targets.

myplot <- ggplot(df_isNA1) +
  geom_line(aes(x=TIMESTAMP, y = value, color = sensor)) +
  ylim(c(0, 500)) +
  xlab("") + 
  ylab("count") +
  theme(legend.position="none")

loopvals <- unique(df_isNA1$plane)

for (i in 1:length(loopvals)){
  print(myplot %+% subset(df_isNA1, plane %in% loopvals[i]) +
          labs(title = paste0(loopvals[i], " isNA (count)")) +
          theme(plot.title = element_text(hjust = 0.5)) +
          facet_grid(target~cam)
  )
}