Reputation: 157
I have a data frame and need to access the 1st row in the 1st column (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
I have tried the following:
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
Upvotes: 2
Views: 760
Reputation: 2411
You can read only the first column from a data frame like this:
x <- df[1,, drop = FALSE]
Upvotes: 1