On Thu, Jul 7, 2011 at 5:24 PM, Dennis Murphy wrote:
> Hi:
>
> Here's another approach using the plyr package:
>
> library(plyr)
> df <- data.frame(gp = factor(rep(1:3, each = 4)), x = rnorm(12), y =
> rnorm(12))
> mylst <- split(df, df$gp)
> mycoefs <- ldply(mylst, function(d) coef(lm(y ~ x, da
Hi:
Here's another approach using the plyr package:
library(plyr)
df <- data.frame(gp = factor(rep(1:3, each = 4)), x = rnorm(12), y = rnorm(12))
mylst <- split(df, df$gp)
mycoefs <- ldply(mylst, function(d) coef(lm(y ~ x, data = d)))
names(mycoefs) <- c('gp', 'intercept', 'slope')
merge(df, myc
Hi,
I've a data frame like this:
> as.data.frame(cbind(rnorm(1:12),rnorm(1:12)))
V1 V2
1 -1.30849402 -0.52094136
2 0.96157302 0.76217871
3 -0.44223351 -1.72630871
4 -0.10432438 -1.04732942
5 -1.38748914 0.95877311
6 -0.63965975 0.65494811
7 -0.24058318 0.19496830
3 matches
Mail list logo