[R] scatterplot x axis specifications

David Winsemius dwinsemius at comcast.net
Tue May 22 21:40:55 CEST 2012


On May 22, 2012, at 1:59 PM, jhartsho wrote:

> I have created a scatter plot that has come out okay but I am having  
> trouble
> with the x axis.  My data consists of 4 treatments but these  
> treatments are
> days so R keeps reading them as numeric and making my x axis  
> continuous.
> Here is what I have so far:
>
>
> plot(pair$MC~pair$Day, pch=c(19,24)[as.factor(Cookie)],
> 	main='Paired t Test',
> 	xlab='Days in Field',
> 	ylab='Moisture Content (Percent)')
>
> I have also done: as.factor(Day) to change it to 4 levels

No. This is more of a functional programming language, not an  
applicative one. There are functions with side-effects but very few  
that will change objects without assignment.

> and when I do
> is.factor(Day) it returns with FALSE.

You probably did not make the assignment..

pair$Day <- factor(pair$Day)

>
> I'm assuming this is the reason that I get the message that my x and y
> lengths differ when trying to convert my x axis using:
>
> axis(side=1, at=c(0,15,30,45)
>
> When I switch my numbers to words (i.e. zero, fifteen...) it only  
> brings up
> a boxplot and I specifically want the points so I can assign  
> different pch
> by group. Am I totally missing something here?

You may have lost me on that one.

axis(side=1, at= at=c(0,15,30,45), labels=c("one","fifteen", "thirty",  
"forty-five")

One _does_ need to read the help page to learn the correct argument  
names.

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list