访问向量中元素
## [1] 1 2 3 4 5 6 7 8 9 10
## [1] 5
## [1] 1 2 3 4 6 7 8 9 10
## [1] 1 5 8
## [1] 1 2 3 4 5
## [1] 2 4 6 8 10
## [1] 6 7 8 9 10
## [1] 5.5
## [1] 6 7 8 9 10
## A B C D E F G H I J
## 1 2 3 4 5 6 7 8 9 10
## A
## 1
## [1] 10
## [1] 1 2 3 4 5 6 7 8 9 10
## [1] 1 2 3 4 100 6 7 8 9 10
## [1] 1 2 3 4 5 6 7 8 9 10
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13
## [1] 1 2 3 4 5 6 7 8 9 10
## [1] 1 2 3 4 5 6 7 8 9 10 11
## [1] 1 2 3 4 5 6 7 8 9 10
## [1] 1 2 3 4 5 6 7 8 9 10
## [1] 11 12 13 1 2 3 4 5 6 7 8 9 10
## [1] 1 2 3 4 5 6 7 8 9 10
## [1] 1 2 3 4 5 11 12 13 6 7 8 9 10
访问列表
## $symbols
## [1] "MSFT" "KO" "CSCO"
##
## $price
## [1] 40.40 40.56 23.02
##
## $currency
## [1] "USD"
##
## $country
## [1] "USA"
##
## $type
## [1] "STOCK"
## $symbols
## [1] "MSFT" "KO" "CSCO"
## [1] "MSFT" "KO" "CSCO"
## [1] "MSFT" "KO" "CSCO"
## [1] "MSFT"
## [1] "MSFT"
## $x
## [1] 1 2 3 4 5 6 7 8 9 10
##
## $y
## [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
## [20] "t" "u" "v" "w" "x" "y" "z"
##
## $z
## $z[[1]]
## [1] 1 2 3 4 5 6 7 8 9 10
## [1] 1 2 3 4 5 6 7 8 9 10
## $x
## [1] 1 2 3 4 5 6 7 8 9 10
## [[1]]
## [1] 1 2 3 4 5 6 7 8 9 10
## [1] 1 2 3 4 5 6 7 8 9 10
## [[1]]
## [1] 1 2 3 4 5 6 7 8 9 10
## [1] "symbols" "price" "currency" "country" "type"
## [1] "symbols" "price" "currency" "country" "type" "TradeDate"
## $plantform
## [1] "FXCM" "FXCM" "FXCM"
## $symbols
## [1] "MSFT" "KO" "CSCO"
##
## $price
## [1] 40.40 40.56 23.02
##
## $currency
## [1] "USD"
##
## $country
## [1] "USA"
##
## $type
## [1] "STOCK"
##
## $TradeDate
## [1] "2014-04-17" "2014-04-17" "2014-04-17"
## $plantform
## [1] "FXCM" "FXCM" "FXCM"
##
## $symbols
## [1] "MSFT" "KO" "CSCO"
##
## $price
## [1] 40.40 40.56 23.02
##
## $currency
## [1] "USD"
##
## $country
## [1] "USA"
##
## $type
## [1] "STOCK"
##
## $TradeDate
## [1] "2014-04-17" "2014-04-17" "2014-04-17"
## [1] "plantform" "symbols" "price" "currency" "country" "type"
## [7] "TradeDate"
## List of 7
## $ plantform: chr [1:3] "FXCM" "FXCM" "FXCM"
## $ symbols : chr [1:3] "MSFT" "KO" "CSCO"
## $ price : num [1:3] 40.4 40.6 23
## $ currency : chr "USD"
## $ country : chr "USA"
## $ type : chr "STOCK"
## $ TradeDate: Date[1:3], format: "2014-04-17" "2014-04-17" ...
## [1] "plantform" "symbols" "price" "currency" "country" "type"
## [7] "TradeDate"
## [1] "plantform" "symbols" "currency" "country" "type" "TradeDate"
访问矩阵
## Time Series:
## Start = c(1991, 130)
## End = c(1991, 135)
## Frequency = 260
## DAX SMI CAC FTSE
## 1991.496 1628.75 1678.1 1772.8 2443.6
## 1991.500 1613.63 1688.5 1750.5 2460.2
## 1991.504 1606.51 1678.6 1718.0 2448.2
## 1991.508 1621.04 1684.1 1708.1 2470.4
## 1991.512 1618.16 1686.6 1723.1 2484.7
## 1991.515 1610.61 1671.6 1714.3 2466.8
## [1] "mts" "ts" "matrix"
## DAX SMI CAC FTSE
## Min. :1402 Min. :1587 Min. :1611 Min. :2281
## 1st Qu.:1744 1st Qu.:2166 1st Qu.:1875 1st Qu.:2843
## Median :2141 Median :2796 Median :1992 Median :3247
## Mean :2531 Mean :3376 Mean :2228 Mean :3566
## 3rd Qu.:2722 3rd Qu.:3812 3rd Qu.:2274 3rd Qu.:3994
## Max. :6186 Max. :8412 Max. :4388 Max. :6179
## EuStockMarkets.DAX EuStockMarkets.SMI EuStockMarkets.CAC EuStockMarkets.FTSE
## 4707022 6279776 4143761 6632096
## rowTotal
## 21762655
## EuStockMarkets.DAX EuStockMarkets.SMI EuStockMarkets.CAC
## 5460.43 7721.3 3939.5
## 5285.78 7447.9 3846.0
## 5386.94 7607.5 3945.7
## 5355.03 7552.6 3951.7
## 5473.72 7676.3 3995.0
## colTotal 4707021.80 6279776.1 4143761.0
## EuStockMarkets.FTSE rowTotal
## 5587.6 22708.83
## 5432.8 22012.48
## 5462.2 22402.34
## 5399.5 22258.83
## 5455.0 22600.02
## colTotal 6632096.3 21762655.20
访问数据框(一种特殊的列表)
df <- data.frame(symbols=c("MSFT","KO","CSCO"),
price=c(40.40,40.56,23.02),
currency=rep("USD",3),
country=rep("USA",3),
type=rep("STOCK",3),stringsAsFactors = FALSE)
df
## symbols price currency country type
## 1 MSFT 40.40 USD USA STOCK
## 2 KO 40.56 USD USA STOCK
## 3 CSCO 23.02 USD USA STOCK
## [1] "data.frame"
## [1] "list"
## symbols price currency country type
## 1 MSFT 40.4 USD USA STOCK
## price
## 1 40.40
## 2 40.56
## 3 23.02
## [1] 40.40 40.56 23.02
## [1] "USD" "USD" "USD"
## [1] "STOCK" "STOCK" "STOCK"