我不确定 RData 包含哪些符号,但是我知道您可以使用 lapply 和 getsymbols 生成许多 xts 的列表。这是我使用谷歌获取当前股票数据的示例。
symbols<-c("AAPL", "AMZN","GOOGL", "F", "GM", "IBM", "ORCL")
List_of_xts<-lapply(symbols, function(sym){
List_of_Xts<-getSymbols(Symbols = sym, src = "google", auto.assign = FALSE)
})
str(List_of_xts)
导致:
> str(List_of_xts)
List of 7
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2794, 1:5] 12.3 12 12.2 12.3 12.3 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "AAPL.Open" "AAPL.High" "AAPL.Low" "AAPL.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:05"
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2794, 1:5] 38.7 38.6 38.7 38.2 37.6 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "AMZN.Open" "AMZN.High" "AMZN.Low" "AMZN.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:06"
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2794, 1:5] 233 235 241 244 243 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "GOOGL.Open" "GOOGL.High" "GOOGL.Low" "GOOGL.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:07"
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2795, 1:5] 7.56 7.56 7.72 7.63 7.75 7.79 7.73 7.77 7.89 7.97 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "F.Open" "F.High" "F.Low" "F.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:08"
$ :An ‘xts’ object on 2010-11-18/2018-02-07 containing:
Data: num [1:1817, 1:5] 35 34.1 34.2 34 33.7 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "GM.Open" "GM.High" "GM.Low" "GM.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:08"
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2795, 1:5] 97.2 97.2 97.6 98.5 99.1 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "IBM.Open" "IBM.High" "IBM.Low" "IBM.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:09"
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2795, 1:5] 17.2 17.6 17.6 17.6 17.9 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "ORCL.Open" "ORCL.High" "ORCL.Low" "ORCL.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:10"> str(List_of_xts)
List of 7
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2794, 1:5] 12.3 12 12.2 12.3 12.3 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "AAPL.Open" "AAPL.High" "AAPL.Low" "AAPL.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:05"
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2794, 1:5] 38.7 38.6 38.7 38.2 37.6 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "AMZN.Open" "AMZN.High" "AMZN.Low" "AMZN.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:06"
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2794, 1:5] 233 235 241 244 243 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "GOOGL.Open" "GOOGL.High" "GOOGL.Low" "GOOGL.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:07"
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2795, 1:5] 7.56 7.56 7.72 7.63 7.75 7.79 7.73 7.77 7.89 7.97 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "F.Open" "F.High" "F.Low" "F.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:08"
$ :An ‘xts’ object on 2010-11-18/2018-02-07 containing:
Data: num [1:1817, 1:5] 35 34.1 34.2 34 33.7 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "GM.Open" "GM.High" "GM.Low" "GM.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:08"
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2795, 1:5] 97.2 97.2 97.6 98.5 99.1 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "IBM.Open" "IBM.High" "IBM.Low" "IBM.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:09"
$ :An ‘xts’ object on 2007-01-03/2018-02-07 containing:
Data: num [1:2795, 1:5] 17.2 17.6 17.6 17.6 17.9 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:5] "ORCL.Open" "ORCL.High" "ORCL.Low" "ORCL.Close" ...
Indexed by objects of class: [Date] TZ: UTC
xts Attributes:
List of 2
..$ src : chr "google"
..$ updated: POSIXct[1:1], format: "2018-02-07 21:48:10"