子集包含日期条件的列表

时间:2017-12-06 22:34:28

标签: r list subset

我有一个清单

wrapper.find(Component).at(index).simulate('click');

以及如何在2014-01-01和2015-01-08之间使用date_start和date_end对列表进行子集化,以及FLAG = 2

我期望的结果就像

CLUST_K <- structure(list(LONGITUDE = c(118.5, 118.5, 118.5, 118.5, 118.5, 
                    118.5), LATITUDE = c(-11.5, -11.5, -11.5, -11.5, -11.5, -11.5
                    ), DATE_START = structure(c(1419897600, 1419984000, 1420070400, 
                    1420156800, 1420243200, 1420329600), class = c("POSIXct", "POSIXt"
                    )), DATE_END = structure(c(1420502400, 1420588800, 1420675200, 
                    1420761600, 1420848000, 1420934400), class = c("POSIXct", "POSIXt"
                    )), FLAG = c(2, 1, 2, 2, 2, 2), SURFSKINTEMP = c(13L, 1L, 16L, 
                    16L, 7L, 13L), SURFAIRTEMP = c(6L, 6L, 6L, 6L, 6L, 6L), TOTH2OVAP = c(5L, 
                    17L, 17L, 17L, 17L, 17L), TOTO3 = c(16L, 16L, 16L, 10L, 7L, 7L
                    ), TOTCO = c(12L, 12L, 8L, 4L, 12L, 12L), TOTCH4 = c(13L, 14L, 
                    6L, 6L, 11L, 7L), OLR_ARIS = c(10L, 4L, 4L, 7L, 5L, 10L), CLROLR_ARIS = c(10L, 
                    4L, 4L, 7L, 5L, 10L), OLR_NOAA = c(10L, 10L, 10L, 10L, 7L, 9L
                    ), MODIS_LST = c(1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("LONGITUDE", 
                    "LATITUDE", "DATE_START", "DATE_END", "FLAG", "SURFSKINTEMP", 
                    "SURFAIRTEMP", "TOTH2OVAP", "TOTO3", "TOTCO", "TOTCH4", "OLR_ARIS", 
                    "CLROLR_ARIS", "OLR_NOAA", "MODIS_LST"), row.names = c(NA, 6L
                    ), class = "data.frame")    

1 个答案:

答案 0 :(得分:0)

您可以使用子集功能

subs = subset(CLUST_K, FLAG == 2 & DATE_START > startdate & DATE_END > enddate)

或者,您可以使用which()来选择所需的行

subs = CLUST_K[which(FLAG == 2 & DATE_START > startdate & DATE_END > enddate),]

编辑:您可能需要在定义CLUST_K

时将结构转换为DataFrame