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 that?s right for you. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Temp JIRI data.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090602/17fbae50/attachment-0002.txt>
Le mardi 02 juin 2009 ? 16:32 +0000, ms.com a ?crit :> 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?>From the depths of my limbic system:? factor ? relevel ? ordered (two different solutions, with varying implications...).
Without a reproducible example (we don't have month and X1999) it is hard to tell for sure, but my guess is that month is an (unordered) factor without the ordering specified, so it defaults to alphabetic. Change it to a factor with the months properly ordered and the plot should match what you want. One possible way to do this is:> month <- factor(month, levels=month.name)Or> month <- factor(month, levels=month.abb)Or if those don't work, then you will need to provide a set of months in the correct order that match with your data. If that does not help, then send us more info on your month variable (str(month)), or better, a full reproducible example. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of ms.com > Sent: Tuesday, June 02, 2009 10:33 AM > To: r forum > Subject: [R] montly mean temp plot > > > 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 that's right for you.
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: 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@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 that’s right for you. > > > ______________________________________________ > R-help@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. > >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]]