I have data with different countries, different years and different values for several variables on each country-year. I am trying to plot several multiple line plots (the lines are these variables/year) for each country.
For some unknown reason, the plots I get in return are empty, when running the following command:
par(mfrow=c(5,5))
mysplits<-split(A,A$country)
for (ii in 1:length(mysplits)) {
adf<-mysplits[[ii]]
snames<- names(mysplits)[ii]
p<-plot(1,
main=paste(snames),
type = "n", xlim=c(1993,2015),
ylab = "value", xlab="years", ylim=c(-50,50))
lines(adf$year, adf$tone, col = "steelblue", lty=5)
lines(adf$year, adf$articles, col = "pink", lty=2)
lines(adf$year, adf$num, col = "red", lty=3)
lines(adf$year, adf$gold, col = "green", lty=6)
legend("bottomright", legend = c("EPE Public","Tone","Coverage","No of Events",
"Conflictual"), col = c("black","steelblue","pink","red","green"),
lty = c(1,5,2,3,6),
cex = 1.5, seg.len=4)
}
Here is the output of dput(head(A)):
structure(list(X = 1:6, country = structure(c(1L, 1L, 1L, 1L,
1L, 1L), .Label = c("AU", "BE", "BU", "DA", "EN", "EZ", "FI",
"FR", "GM", "HR", "HU", "IT", "LG", "LH", "LO", "LU", "MT", "NL",
"PL", "RO", "SI", "SP", "SW"), class = "factor"), year = 1994:1999,
gold = c(-0.571428571, -2.4, 1.26, -0.2, -0.966666667, 0.316666667
), tone = c(324L, 239L, 251L, 72L, 61L, 159L), articles = c(3.571428571,
4.5, 8.2, 4.6, 9.333333333, 6.166666667), num = c(7L, 4L,
5L, 5L, 6L, 6L), yepe = 1995:2000, couepe = structure(c(1L,
1L, 1L, 1L, 1L, 1L), .Label = c("AU", "BE", "BU", "DA", "EN",
"EZ", "FI", "FR", "GM", "HR", "HU", "IT", "LG", "LH", "LO",
"LU", "MT", "NL", "PL", "RO", "SI", "SP", "SW"), class = "factor"),
epepub = c(2.01, 1.87, 0.55, 0.63, 0.52, 0.82), epepriv = c(NA,
NA, 2.63, 2.71, 2.59, 2.12), epeind = c(0.65, 0.66, 0.72,
0.63, 0.57, 0.53)), .Names = c("X", "country", "year", "gold",
"tone", "articles", "num", "yepe", "couepe", "epepub", "epepriv",
"epeind"), row.names = c(NA, 6L), class = "data.frame")
Here is an image of my data:


dput(head(a))and edit it into your opening post. Before doing this, make sure that you can replicate your problem withhead(a). Also, what do you mean with empty plots? Do the axes still show up or is everything white?par(mfrow=c(1,1)). If this does work and gives a plot, then the problem is that you are trying to get too many plots on a single display. Withpar(mfrow=c(5,5))each plot does not have enough room to be displayed. At least that is what seems to happen when I try to run the script.pdf('plots.pdf'); par(mfrow=c(5,5)); for (...); dev.off()