R - 如何从单列数据框中提取元素?

时间:2017-08-29 19:18:02

标签: r dataframe

我有一个数据框,需要访问第一列的第一行(Negative = 16)

[[1]]
              data
Negative        16
Neutral         36
Positive        28
Very Negative    7
Very Positive   19

List of 1
 $ :'data.frame':   5 obs. of  1 variable:
  ..$ data: int [1:5] 16 36 28 7 19

我尝试了以下内容:

x(1,1)
# Error in x(1, 1) : could not find function "x"

x[1,1]
# Error in x[1, 1] : incorrect number of dimensions

x['Negative',1]
# Error in x["Negative", 1] : incorrect number of dimensions

x['Negative']
# $<NA>
# NULL

1 个答案:

答案 0 :(得分:1)

您只能从数据框中读取第一列,如下所示:

<Error>
<Code>
AccessDenied
</Code>
<Message>
Access Denied
</Message>
<RequestId>
RequestId
</RequestId>
<HostId>
HostId
</HostId>
</Error>