r - Not aggregating correctly -
my goal of code create loop aggregates each company's word frequency principle vector created , adds list. problem is, after run this, prints 7 principles have rather word frequencies along side them. word frequencies being column of freqbyprinc.ag data frame. individually, running code without loop , testing out column, works no problem. reason, loop doesn't want give me correct data frames list. suggestions?
list.agg<-vector("list",ncol(freqbyprinc.ag)-2) (i in 1:14){ attach(freqbyprinc.ag) list.agg[i]<-aggregate(freqbyprinc.ag[,i+1],by=list(type=principle),fun=sum,na.rm=true) }
i wish help. after reading statement, seems , feel code should working , not. maybe there exists glitch.
since had specified list. agg list, need subset double square brackets. try 1 out:
list.agg<-vector("list",ncol(freqbyprinc.ag)-2) (i in 1:14){ list.agg[[i]]<-aggregate(freqbyprinc.ag[,i+1],by=list (type=principle),fun=sum,na.rm=true)}
Comments
Post a Comment