【发布时间】:2011-09-18 05:51:44
【问题描述】:
是否可以直接访问 data.frame 中的向量元素?
# DataFrame
nerv <- data.frame(
c(letters[1:10]),
c(1:10)
)
str(nerv)
# Accessing 5th element of the second variable/column
# This should give "5", but it does NOT work
nerv[2][5]
# Works, but I need to know the NAME of the column
nerv$c.1.10.[5]
我尝试了几件事,但都没有奏效。我只有列的索引,但没有名称,因为我想使用循环来插入多个列。
看来我有一个基础知识空白,希望你能帮我填补。
【问题讨论】: