在 R 中建立向量的限制是什麼?
在 R 中建立向量的限制有四個。我們在建立任何型別的向量時必須記住這些限制:
向量名稱不能有 % 符號。
向量名稱不能以數字開頭。
向量可以以點開頭,但其後不應有數字。
向量不能以下劃線開頭。
示例
帶有 % 符號的向量 -
x1%<-1:20 Error: unexpected input in "x1%<-1:20" x1%first<-1:20 Error: unexpected input in "x1%first<-1:20" %x1<-1:20 Error: unexpected input in "%x1<-1:20" x1_%_first<-1:20 Error: unexpected input in "x1_%_first<-1:20" x1first_1_%<-1:20 Error: unexpected input in "x1first_1_%<-1:20" x1first__%<-1:20 Error: unexpected input in "x1first__%<-1:20"
以數字開頭的向量 -
1x<-1:20 Error: unexpected symbol in "1x" 1_x<-1:20 Error: unexpected input in "1_" 101_x<-1:20 Error: unexpected input in "101_" 123_x<-1:20 Error: unexpected input in "123_" 1number_x<-1:20 Error: unexpected symbol in "1number_x" 1number<-1:20 Error: unexpected symbol in "1number"
以點開頭的向量 -
.x1<-1:10 .x1 [1] 1 2 3 4 5 6 7 8 9 10 .1x<-1:10 Error: unexpected symbol in ".1x" .1_x<-1:10 Error: unexpected input in ".1_" .100_x<-1:10 Error: unexpected input in ".100_" .1of_x<-1:10 Error: unexpected symbol in ".1of_x" .2of_x<-1:10 Error: unexpected symbol in ".2of_x" .1ofx<-1:10 Error: unexpected symbol in ".1ofx"
以下劃線開頭的向量 -
_x1<-1:10 Error: unexpected input in "_" _first<-1:10 Error: unexpected input in "_" _first_variable<-1:10 Error: unexpected input in "_" _variable1<-1:10 Error: unexpected input in "_" _firstvariable<-1:10 Error: unexpected input in "_" _V1<-1:10 Error: unexpected input in "_" _1_var <-1:10 Error: unexpected input in "_"
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP