Re: [R] Basic question: why does a scatter plot of a variable against itself works like this?

2013-11-06 Thread Marc Schwartz
On Nov 6, 2013, at 10:40 AM, Tal Galili tal.gal...@gmail.com wrote: Hello all, I just noticed the following behavior of plot: x - c(1,2,9) plot(x ~ x) # this is just like doing: plot(x) # when maybe we would like it to give this: plot(x ~ c(x)) # the same as: plot(x ~ I(x)) I was

Re: [R] Basic question: why does a scatter plot of a variable against itself works like this?

2013-11-06 Thread William Dunlap
It probably happens because plot(formula) makes one call to terms(formula) to analyze the formula. terms() says there is one variable in the formula, the response, so plot(x~x) is the same a plot(seq_along(x), x). If you give it plot(~x) , terms() also says there is one variable, but no response,

Re: [R] Basic question: why does a scatter plot of a variable against itself works like this?

2013-11-06 Thread Barry Rowlingson
Interestingly, fitting an LM with x on both sides gives a warning, and then drops it from the RHS, leaving you with just an intercept: lm(x~x,data=d) Call: lm(formula = x ~ x, data = d) Coefficients: (Intercept) 4 Warning messages: 1: In model.matrix.default(mt, mf, contrasts) :