是否可以直接訪問data.frame中的向量元素?直接訪問R中data.frame中的Vector元素?
# 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]
我嘗試了幾件事情,但都沒有工作。我只是列的索引,但沒有名稱,因爲我想要使用循環來交織幾列。
看來我有一個基本的知識缺口,我希望你能幫我填補它。
我已經嘗試過'NERV [2,5 ]',但它給出了NULL。我也嘗試過諸如'as.vector(nerv [2])[5]' –
之類的東西,這是回到前面,第一行,第二列。你們都有這個錯誤的方式。 –
@Gavin,我相信@約翰犯了一個錯字... [修正]。 – aL3xa