correction...
Col and rows were mixed up and loop only worked when rows were less than or
equal to number of columns
//M
test<-function(a){
coef(summary(a))->lo
a<-colnames(lo)
b<-rownames(lo)
c<-length(a)
e<-character(0)
r<-NULL
for (x in (1:length(b))){
d<-rep(paste(a[1:c
Upon reading the plyr documentation that was the distinct impression I got and
I´m glad that "whatever expectations I had developed regarding plyr" were
fulfilled. Thx for the input Hadley.
Maybe this is a cumbersome solution, but it works..
And Matthew, I will most definitively look into t
On Mon, Aug 9, 2010 at 4:30 PM, Matthew Dowle wrote:
>
>
> Another option for consideration :
>
> library(data.table)
> mydt = as.data.table(mydf)
>
> mydt[,as.list(coef(lm(y~x1+x2+x3))),by=fac]
> fac X.Intercept. x1 x2 x3
> [1,] 0 -0.16247059 1.130220 2.988769 -19.14719
Another option for consideration :
library(data.table)
mydt = as.data.table(mydf)
mydt[,as.list(coef(lm(y~x1+x2+x3))),by=fac]
fac X.Intercept. x1 x2x3
[1,] 0 -0.16247059 1.130220 2.988769 -19.14719
[2,] 1 0.08224509 1.216673 2.847960 -19.16105
[3,] 2 0.020523
>> That's exactly what dlply does - so you should never have to do that
>> yourself.
>
> I'm unclear what you are saying. Are you saying that the plyr function
> _should_ have examined the objects in that list and determined that there
> were 4 rows and properly labeled the rows to indicate which l
On Aug 9, 2010, at 12:47 PM, Hadley Wickham wrote:
There is one further improvement to consider. When I tried using
dlply to
tackle a problem on which I had been bashing my head for the last
three days
and it gave just the results I had been looking for, I also noticed
that the
dlply func
ldply doesnt need a grouping variable as far as I understand the command..
"Description
For each element of a list, apply function then combine results into a data
frame
Usage
ldply(.data, .fun = NULL, ..., .progress = "none")"
regards,
M
On 9. aug. 2010, at 15.33, David Winsemius wrote:
> There is one further improvement to consider. When I tried using dlply to
> tackle a problem on which I had been bashing my head for the last three days
> and it gave just the results I had been looking for, I also noticed that the
> dlply function returns the grouping variable levels in an attri
On Aug 9, 2010, at 10:11 AM, moleps wrote:
ldply doesnt need a grouping variable as far as I understand the
command..
There is one further improvement to consider. When I tried using dlply
to tackle a problem on which I had been bashing my head for the last
three days and it gave just th
On Mon, Aug 9, 2010 at 9:29 AM, David Winsemius wrote:
> If you look at the output (as I did) you should see that despite whatever
> expectations you have developed regarding plyr, that it did not produce a
> grouping variable:
>
>> ldply(dl, function(x) coef(summary(x)) )
> fac Estimate Std
If you look at the output (as I did) you should see that despite
whatever expectations you have developed regarding plyr, that it did
not produce a grouping variable:
> ldply(dl, function(x) coef(summary(x)) )
facEstimate Std. Error t value Pr(>|t|)
10 -0.3563418 0.14383
On Aug 9, 2010, at 7:51 AM, moleps wrote:
Dear all,
I´m having trouble getting a list of regression variables back into
a dataframe.
mydf <- data.frame(x1=rnorm(100), x2=rnorm(100), x3=rnorm(100))
mydf$fac<-factor(sample((0:2),replace=T,100))
mydf$y<- mydf$x1+0.01+mydf$x2*3-mydf$x3*19+rn
Dear all,
I´m having trouble getting a list of regression variables back into a
dataframe.
mydf <- data.frame(x1=rnorm(100), x2=rnorm(100), x3=rnorm(100))
mydf$fac<-factor(sample((0:2),replace=T,100))
mydf$y<- mydf$x1+0.01+mydf$x2*3-mydf$x3*19+rnorm(100)
dlply(mydf,.(fac),function(df) lm(y~
13 matches
Mail list logo