Re: [R] Question about syntax in lm function

2011-09-25 Thread Ben Bolker
阮铮 foxmail.com> writes: > I encounters some codes in ggplot2 manual and confused with one of > its lm syntax. [snip] mod <- lm(lprice2 ~ lcarat * color, data = d) > # *** what puzzled me is the > last statement marked with ***. How does R deal with lcarat * color, > since color is not of num

[R] Question about syntax in lm function

2011-09-25 Thread 阮铮
I encounters some codes in ggplot2 manual and confused with one of its lm syntax. The code is here: library(ggplot2) d <- subset(diamonds, carat < 2.5 & rbinom(nrow(diamonds), 1, 0.2) == 1) d$lcarat <- log10(d$carat) d$lprice <- log10(d$price) detrend <- lm(lprice ~ lcarat, data = d) d$lprice2