[R] montly mean temp plot

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Jun 2 22:47:11 CEST 2009


On Tue, 2009-06-02 at 15:31 -0400, jim holtman wrote:
> THe problem is that when you read the data in, 'month' was converted to a
> factor.  Try the following to get it converted to a factor, but in the order
> you want for processing:

That doesn't need to be a problem, an alternative that works with this
feature is:

> tmp <- read.table("Temp_JIRI_data.txt", sep = "\t", 
                    na.strings = "DNA", header = TRUE)
> tmp <- within(tmp, month <- factor(month, levels = month.name))
> plot(X1999 ~ month, data = tmp)

We can leave it as a factor when being read in, and then relevel it
easily by "converting" it to a factor and specifying the levels using
the in-built constant/vector 'month.name'.

G

> 
> x <- read.table(yourFile, ..., as.is=TRUE, na.strings="DNA")  # prevent
> conversion to factor
> x$month <- factor(x$month, levels=x$month)
> 
> This will create the factor levels in the order you want.
> On Tue, Jun 2, 2009 at 12:32 PM, ms.com <loginms at hotmail.com> wrote:
> 
> >
> > Dear all
> > i got a problem in monthly mean temperature. here i am attaching the data
> > set as well as the plot i got with the following command
> > plot(month,type='n')
> > plot(month,X1999)
> >
> > this command gave the plot where the month names are in alphabetic order, i
> > want the plot in monthly sequence
> > could you please suggest me how can i solve my problem?
> >
> > thanking you
> >
> > regard
> > madan
> >
> > _________________________________________________________________
> > Lauren found her dream laptop. Find the PC thats right for you.
> >
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list