[R] abline function : plot.new has not been called yet

Frederic Ntirenganya ntfredo at gmail.com
Sun Dec 14 08:05:52 CET 2014


Hi All,

I would like to have an idea of how I can solve this error.

I am getting the following error in plotting:

> abline(regn,col='red',lwd=1.5 , data=BUTemp)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) :
  plot.new has not been called yet

This is the str of my data set

> str(BUTemp)
'data.frame':    7671 obs. of  6 variables:
 $ Year : int  1971 1971 1971 1971 1971 1971 1971 1971 1971 1971 ...
 $ Month: Factor w/ 12 levels "Aug","Sep","Oct",..: 2 2 2 2 2 2 2 2 2 2 ...
 $ Day  : int  1 2 3 4 5 6 7 8 9 10 ...
 $ Rain : num  0 0 0 0 0 0 0 0 0 0 ...
 $ Tmax : num  24.3 25 25.6 26.5 27.8 27.5 25.7 25.1 26.5 25.1 ...
 $ Tmin : num  13.5 13.2 12.7 12.7 12.2 14 13.2 12.3 12.8 11.7 ...

The code I am using is :

require(latticeExtra) # trellis plot for temperature and rain.
require(lattice)

levels(BUTemp$Month) <- c("Aug", "Sep", "Oct", "Nov", "Dec", "Jan",
                          "Feb", "Mar", "Apr", "May", "Jun", "Jul")

xyplot(BUTemp$Tmin + BUTemp$Tmax ~ BUTemp$Year | BUTemp$Month,
       data =BUTemp , type = "b", pch=19)

regn=lm(BUTemp$Tmin + BUTemp$Tmax ~ BUTemp$Year)

abline(regn,col='red',lwd=1.5)
summary(regn)

Thanks  for your help.

Regards,
Frederic.
Frederic Ntirenganya
Maseno University,
African Maths Initiative,
Kenya.
Mobile:(+254)718492836
Email: fredo at aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/

	[[alternative HTML version deleted]]



More information about the R-help mailing list