Plot only diagonal entries with data.frame of many time-series in R

I have several time series, which when I plot using,

plot(na.omit(d))

I get the following graph:

Instead of this entire matrix of plots, I only want the ones from the diagonal. In other words, I don't want to plot the combinations of different time series.

The following very messy code achieves what I want, but I was wondering if there were a simpler, more compact way to accomplish this:

png('./Pictures/acf1.png')
plot(acf(na.omit(f$C1)))
png('./Pictures/acf2.png')
plot(acf(na.omit(f$C2)))
png('./Pictures/acf3.png')
plot(acf(na.omit(f$C3)))
png('./Pictures/acf4.png')
plot(acf(na.omit(f$C4)))
png('./Pictures/acf5.png')
plot(acf(na.omit(f$C5)))
png('./Pictures/acfCO2.png')
plot(acf(na.omit(f$MLCO2)))

png('./Pictures/pacf1.png')
plot(pacf(na.omit(f$C1)))
png('./Pictures/pacf2.png')
plot(pacf(na.omit(f$C2)))
png('./Pictures/pacf3.png')
plot(pacf(na.omit(f$C3)))
png('./Pictures/pacf4.png')
plot(pacf(na.omit(f$C4)))
png('./Pictures/pacf5.png')
plot(pacf(na.omit(f$C5)))
png('./Pictures/pacfCO2.png')
plot(pacf(na.omit(f$MLCO2)))

Maybe something similar to this?

for(i in d) 
{
    png(PACF$i.png)
    plot(pacf(na.omit(d$i)))
}

Answers


Try:

 for(i in 1:ncol(d)){
png(paste('c:/zzz/',i,'.png',sep =''))
plot(pacf(na.omit(d[,i])))
dev.off()
}

For './Pictures/pacfCO2 try something like:

png(paste('./Pictures/pacf',i,'.png',sep=''))

Need Your Help

Jquery redirect with Ajax Calls to another page Rails

ruby-on-rails ajax ruby-on-rails-3 jquery

I am trying to implement two pages. The first page being a selection of the items I want to show on the second page.