Get only the value of an element in an R data frame (without the index)
dataframe, indexing, r
Solution
Double the square brackets.
d1 <- data.frame(a=1:5, b=rnorm(5))
d1$b[[3]]
That should do it. But there are many ways to do this...
Problem
I have a small data frame lie this: ``` > testdfcompound_1 E1 E2 2012-05-17 01:00:58 20.94700 2.148299 2012-05-17 01:01:57 15.36875 2.199166 2012-05-17 01:02:56 19.05800 2.697803 2012-05-17 01:03:55 17.90500 2.358735 ``` And I want to get only the E1 value of the 1st element, so, 20.94700. But I can't find a way to get it. If I try: `testdfcompound_1$E1[1]`, I'm getting: ``` > testdfcompound_1$E1[1] E1 2012-05-17 01:00:58 20.947 ``` How do I get only the 20.947 ?