this solution using dplyr may work if you are sure that rounding the “timestamp” to the nearest minute will give a unique identifier in combination with the “address”:
library(readr)
library(dplyr)
Hdata_soil <- readr::read_csv("X_id,timestamp,address,rssi,batt_v,soil_temp_1,soil_temp_2,soil_temp_3,soil_moisture_1
565846060dd8e408e3817c58,27/11/2015 12:01:10,A8,-65,NA,NA,NA,NA,NA
565846070dd8e408e3817c59,27/11/2015 12:01:11,A8,NA,NA,9.73,-273.15,14.63,647
565846cf0dd8e408e3817caf,27/11/2015 12:04:31,A7,-64,NA,NA,NA,NA,NA
565846cf0dd8e408e3817cb0,27/11/2015 12:04:31,A7,NA,NA,8.56,9.46,9.64,660
565847650dd8e408e3817cf5,27/11/2015 12:07:01,A8,-64,NA,NA,NA,NA,NA
565847660dd8e408e3817cf6,27/11/2015 12:07:02,A8,NA,NA,9.82,-273.15,14.29,643")
Hdata_soil <- dplyr::mutate(
Hdata_soil,
timestamp = as.POSIXct(strptime(timestamp, format = "%d/%m/%Y %H:%M:%S"))
, timestamp_round = as.POSIXct(round(timestamp, units = "mins"))
) %>%
dplyr::group_by(timestamp_round, address) %>%
dplyr::summarise_each(
funs(min(., na.rm = TRUE))
)
What gives:
> # Print
> Hdata_soil
Source: local data frame [3 x 10]
Groups: timestamp_round [?]
timestamp_round address X_id timestamp rssi batt_v soil_temp_1 soil_temp_2 soil_temp_3 soil_moisture_1
(time) (chr) (chr) (time) (int) (lgl) (dbl) (dbl) (dbl) (int)
1 2015-11-27 12:01:00 A8 565846060dd8e408e3817c58 2015-11-27 12:01:10 -65 NA 9.73 -273.15 14.63 647
2 2015-11-27 12:05:00 A7 565846cf0dd8e408e3817caf 2015-11-27 12:04:31 -64 NA 8.56 9.46 9.64 660
3 2015-11-27 12:07:00 A8 565847650dd8e408e3817cf5 2015-11-27 12:07:01 -64 NA 9.82 -273.15 14.29 643