Reputation: 1154
I have a package which returns list
in variable "res".
res[1] looks like this
> res[1]
$anoms
timestamp anoms
1 2017-02-08 20:15:00 7695
2 2017-06-09 20:26:00 4013
3 2017-02-01 20:14:00 85029
4 2017-02-07 20:14:00 7214
5 2017-09-23 08:49:00 4422
6 2017-01-31 20:14:00 84431
7 2017-09-22 08:47:00 4529
As you can see both columns (timestamp and anoms) are in 1 position.
How can I transform this list into a Data Frame with three columns, where 1st and 2nd are timestamp and anoms, and third is a static variable which was defined before (say variable a<-"test")
Upvotes: 0
Views: 1100
Reputation: 18681
Posting this as an answer so people can see it:
df = res[1]$anoms
df$a = "test"
You can use $
to extract the anoms
element of the list (which is a data.frame in this case).
Upvotes: 2