-1

I have an R object as follows. How can I get level column data? components$level does not work. I also gave the attributes below.

> unclass(components)
            observed       level         slope       season1       season2
   [1,] 0.0084075449 0.007172836 -8.528225e-06  3.291206e-04 -8.909450e-04
   [2,] 0.0093858797 0.007214750 -8.594915e-06 -2.346916e-05 -8.712144e-04
   [3,] 0.0091792334 0.007257663 -8.663195e-06 -3.583402e-04 -8.507308e-04
   [4,] 0.0086728344 0.007292330 -8.718353e-06 -4.233460e-04 -8.295280e-04
   [5,] 0.0069083084 0.007293365 -8.720000e-06 -1.695487e-04 -8.076499e-04

> attributes(components)
$dim
[1] 1327    5

$dimnames
$dimnames[[1]]
NULL

$dimnames[[2]]
[1] "observed" "level"    "slope"    "season1"  "season2" 


$tsp
[1] 2011.00 2014.63  365.25

$class
[1] "mts"    "ts"     "matrix"
1
  • components is a matrix, not a data frame, so you can't use $ to access columns. Try components[,"level"] Commented Dec 10, 2014 at 18:39

1 Answer 1

1

It'd help to show how components was initialized but my best guess is

components[,'level']
Sign up to request clarification or add additional context in comments.

2 Comments

The first should work, but unlikely the second will.
I'm not familiar with attributes(), I thought maybe $dimnames[[2]] was referring to something else, but it occurs to me its just row=1, column=2, so I'll edit

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.