r - Adding variable columns and values to empty list -
r - Adding variable columns and values to empty list -
i trying iterate through different datasets, extracting numbers them. name of each dataset used column of list, numbers should added column. in illustration not work:
> liste<-list() > (i in c("di","mi","do")){print(i); liste$i<-c(liste$i,4)} [1] "di" [1] "mi" [1] "do" > liste $i [1] 4 4 4 starting empty list, want add together column called "di", , add together value 4 (lateron more values) column. however, r doesn't utilize variable, calls columns i. how can prepare problem?
use [ instead of $:
liste<-list() (i in c("di","mi","do")){print(i); liste[[i]]<-4} liste r list variables append
Comments
Post a Comment