[R] plot xaxp issue

PIKAL Petr petr.pikal at precheza.cz
Tue Jan 8 08:36:37 CET 2013


Hi

I actually do not know what you are talking about. I believe that the code I provided works (if i did not make typing mistake), but you failed to provide data to test so I made my own data and subset inside lm works as expected.

fake<-data.frame(weight<-rnorm(15), length=weight*3+rnorm(15), sex=rep(c("b","g"), c(7,8)))
names(fake)[1]<-"weight"
plot(fake$length, fake$weight, col=as.numeric(fake$sex))
bl<-lm(weight~length, data=fake, subset=sex=="b")
abline(bl)
gl<-lm(weight~length, data=fake, subset=sex=="g")
abline(gl, col=2)

Beware that R is smart but not smart enough to correct user typing mistakes (missing parntheses, missing commas, etc.). Typing mistakes are probably the most common source of failing code.

Regards

Petr

> -----Original Message-----
> From: Elaine Kuo [mailto:elaine.kuo.tw at gmail.com]
> Sent: Tuesday, January 08, 2013 2:03 AM
> To: PIKAL Petr
> Cc: r-help at r-project.org
> Subject: Re: [R] plot xaxp issue
> 
> Hello,
> 
> I figured out that the code should be
> 
> boyline<-lm(body_weight ~ body_length, data=subset
> (together,,sex=="boy"))
> 
> However, the "" could be omitted if the field name happened to be
> numeric, such as 1, 2, or 3.
> Please kindly explain why the "" could be omitted for numbers.
> Thanks again.
> 
> Elaine
> On Tue, Jan 8, 2013 at 8:40 AM, Elaine Kuo <elaine.kuo.tw at gmail.com>
> wrote:
> > boyline<-lm(body_weight ~ body_length, data=together,
> > subset(together,sex=="boy"))




More information about the R-help mailing list