R語言從基礎入門到提高(三)Vectors(向量)
阿新 • • 發佈:2019-01-29
Working with comparisons will make your data analytical life easier. Instead of selecting a subset(子集) of days to investigate(研究) yourself (like before), you can simply ask R to return only those days where you realized a positive return for poker.
In the previous exercises you used selection_vector <- poker_vector > 0
You can select the desired(渴望的) elements, by putting selection_vector
between
the square brackets that follow poker_vector
:
R knows what to do when you pass a logical vector in square brackets: it will only select the elements that correspond to(對應是)poker_vector[selection_vector]
TRUE
in selection_vector
.