ベクトルから要素抽出

> dataset <- read.table("clipboard" , header=TRUE)

> dataset
        Date Value
1   1891/1/1 -0.86
2   1891/2/1 -0.86
3   1891/3/1 -0.74
4   1891/4/1 -0.63
5   1891/5/1 -0.54
6   1891/6/1 -0.62
7   1891/7/1 -0.61
8   1891/8/1 -0.58
9   1891/9/1 -0.44
10 1891/10/1 -0.55
11 1891/11/1 -0.79
12 1891/12/1 -0.45

> y<-dataset$Value

> y[12]
[1] -0.45

> y[10:12]
[1] -0.55 -0.79 -0.45

> y[ c(10,12)]
[1] -0.55 -0.45

> y[-12]
 [1] -0.86 -0.86 -0.74 -0.63 -0.54 -0.62 -0.61 -0.58 -0.44 -0.55 -0.79

> y[-(10:12)]
[1] -0.86 -0.86 -0.74 -0.63 -0.54 -0.62 -0.61 -0.58 -0.44

> y[-c(10,12)]
 [1] -0.86 -0.86 -0.74 -0.63 -0.54 -0.62 -0.61 -0.58 -0.44 -0.79