[R] plotting a point graph with data in X-axis
ramasamy at cancer.org.uk
Wed May 9 03:21:17 CEST 2007
R understands only numerical and Date class values for axis. So either
a) plot them using the sequence 1, ..., 32 and then explicitly label
them. Here is an example:
n <- length(year.month)
plot( 1:n, freq, xaxt="n")
mtext( text=year.month, side=1, at=1:n, las=2 )
b) or create the dates in Date format. This option is preferable if the
dates were varying unequally.
x <- seq( as.Date("2000-05-01"), as.Date("2002-12-01"), by="1 month" )
BTW, you could also have created year.month via
paste( rep( 2000:2002, c(8,12,12) ),
formatC( c(5:12,1:12,1:12), width=2, flag="0" ) , sep="_" )
Milton Cezar Ribeiro wrote:
> Dear all,
> I have two data frame, on with a complete list of my field survey with frequency data of a sample species. This data frame looks like:
> plot(year.month, freq)
> As you can see, I have a collumn with the year and month of my samples, and a freq variable with simulated data. I would like to plot this data but when I try to use the plot showed above, I get a error message.
> After bypass this problem, I would like add points in my graph with simulated data for only a random number of survey month, but I need that the full range of surveys be kept on the X-axis. Just to simulate a sample I am using:
> simulation.sample<-simulation[sample(1:length(year.month),8, replace=F),]
> Any ideas?
> Kind regards
> [[alternative HTML version deleted]]
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help