次のデータフレームがあります。
myDates <- seq(as.Date("2013/1/1"), as.Date("2013/1/10"), "days");
x1 <- 1:10
y1 <- 11:20
myTable <- data.frame(myDates, x1, y1)
ここで、日付を 2 日間の間隔に分割してから、おそらくループを使用してファイルにx1
プロットy1
し、最終的に.png
5 png files
私の考えは、関数を使用して を 2 日の間隔に分割し、次に a を使用して、次のように異なるレベルに 1 つずつプロットすることでした。data.frame
split
cut
for-loop
twoDayInt <- seq(as.Date("2013/01/01"), as.Date("2013/01/10"), by = "2 days")
myTableSplit <- split(myTable, cut(myTable$myDates, twoDayInt))
for (j in 1:length(twoDayInt)) {
fileName <- sprintf("/home/kigode/Desktop/%s_2dayInteval_%02i.png ", "myGraph",j)
png(fileName,width=700,height=650)
# this is where i cant figure out what to put
plot(myTableSplit$x1[j], myTableSplit$y1[j])
}
dev.off()
今、私は for ループ セクションで立ち往生しており、続行する方法についての手がかりを求めています。