Hi, May be this helps:
dat1<-read.table(text=" Date Var day 1/1/2013 1 Tue 1/2/2013 2 Wed 1/3/2013 3 Thu 1/4/2013 4 Fri 1/5/2013 5 Sat 1/6/2013 6 Sun 1/7/2013 7 Mon 1/8/2013 8 Tue 1/9/2013 9 Wed 1/10/2013 10 Thu ",sep="",header=TRUE,stringsAsFactors=FALSE) dat1$days<-as.numeric(format(as.Date(dat1$Date,format="%m/%d/%Y"),"%w")) plot(Var~days,data=dat1,xaxt="n",xlab="Day of week") axis(1,at=dat1$days,labels=dat1$day) A.K. ----- Original Message ----- From: Ye Lin <ye...@lbl.gov> To: R help <r-help@r-project.org> Cc: Sent: Tuesday, May 21, 2013 7:22 PM Subject: [R] x axis problem when plotting Hey I have a dataset like this: Date Var day 1/1/2013 1 Tue 1/2/2013 2 Wed 1/3/2013 3 Thu 1/4/2013 4 Fri 1/5/2013 5 Sat 1/6/2013 6 Sun 1/7/2013 7 Mon 1/8/2013 8 Tue 1/9/2013 9 Wed 1/10/2013 10 Thu And I want to plot Var~day Here is the code I use: plot(Dataset$Var~Dataset$day,xlab='Day of a week') Then I get this error message: ERROR: need finite 'xlim' values When I use similar code to plot Var~Date, it works fine. I have tired plot the line first then add X axis using axis(1,Dataset$day), it doesnt work either. Really appreciate your help! [[alternative HTML version deleted]] ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code. ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.