如何从R中的变量命名列表项?

时间:2016-11-30 20:27:43

标签: r

我已经看到了其他类似的问题,但对我来说并不是非常具体,我可以建立连接。

我试图拥有一个对象列表,这样我就可以使我的程序有点模块化。它们应该基于州名,如下面的代码所示:

statedata <- list()
for (i in state.name){
   date <- somedates # vector from a dataframe
   statedata <- c(statedata,list(i=dates))
}
然而,我最终得到的是:

  

&GT;名字(statedata)
  [1]&#34;我&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34;
  [29]&#34;我&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34; &#34; I&#34;

有没有办法为列表中的每个向量赋一个变量的名称?

0 个答案:

没有答案