R - 仅绘制csv文件中的某些数据行

时间:2015-11-15 19:49:15

标签: r csv plot

所以我已经在多个站点的一天内制作了平均浓度图,但现在我只想从早上10点到11点获取数据。这是原始图表的代码:

hourly_file<-"/Users/bob111higgins/Downloads/hourly_88502_2013.csv"
hourly_table<-read.csv(hourly_file)


hourly_nj <- which(hourly_table$State.Code=="34")#only nj sites
hourly_nj_table<-hourly_table[hourly_nj,]#create a table

write.csv(hourly_nj_table,file="/Users/bob111higgins/Downloads/hourly_88502_2013_NJ.csv")#create new file so it's faster to load
#unique sites
sites<-(unique(hourly_nj_table[,c("State.Code","County.Code","Site.Num")]))#shows all sites since some counties have more than one

#mean diurnal plots for each site
for (k in 1:nrow(sites)) {
  temp_title <- paste("site",k, "county", sites[k,2],"site",sites[k,3])
  l<-which(hourly_nj_table$County.Code==sites[k,2]&hourly_nj_table$Site.Num==sites[k,3])#grab data for each site individually
  temp_filename<-paste("/Users/bob111higgins/Documents/School/College/Rutgers/Atmospheric Research",temp_title,".pdf")
  PM_site<-hourly_nj_table[l,]
  PM_site$realTime<-as.numeric(PM_site$Time.Local)
  PM_mean_site <-aggregate(PM_site, by=list(PM_site$Time.Local),FUN="mean",na.rm=TRUE)  #Make it average by time of day so can make time series plots. 
  plot(PM_mean_site$realTime,PM_mean_site$Sample.Measurement, type="l",lwd=10,main=paste(temp_title),xlab="LocalTime",ylab="Ozone (ppm)")#, ylim = range(0,15))
}

我试图选择上午10点,

timemorn <- which(PM_site$realTime == "10")

但我认为这只是给了我上午10点收集数据的行

  

头(timemorn)   [1] 10 33 57 81 105 129

感谢您的帮助!

0 个答案:

没有答案