如何从R中的每小时数据中选择每天一小时?

时间:2014-04-04 09:00:47

标签: r

我有一张表可以读作:

data=read.table("C:\\users\\product0101.txt",sep="", header  = TRUE, row.names=NULL)

表格如下:

    which is hourly data for three years so 24 values for each day. 

情节 我们只是这样做:

     plot(data$sm, data$date,col='red')

但我想提取(供以后使用)并仅绘制每天04:00对应的值。任何帮助,请

    dput(head(data))
structure(list(Date = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("2006/01/01", 
    "2006/01/02", "2006/01/03", "2006/01/04", "2006/01/05", "2006/01/06", 
    "2006/01/07", "2006/01/08", "2006/01/09", "2006/01/10", "2006/01/11", 
    "2006/01/12", "2006/01/13", "2006/01/14", "2006/01/15", "2006/01/16", 
    "2006/01/17", "2006/01/18", "2006/01/19", "2006/01/20", "2006/01/21", 
    "2006/01/22", "2006/01/23", "2006/01/24", "2006/01/25", "2006/01/26", 

2 个答案:

答案 0 :(得分:2)

第二次编辑:

data$Date <- as.Date(as.character(data$Date), "%y/%m/%d")
plot(data$sm[data$time=="04:00"], data$Date[data$time=="04:00"], col='red')

答案 1 :(得分:1)

只需使用:

plot(data$sm[data$time=="04:00",], data$date, col='red')