Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
What are the restrictions on creating a vector in R?
There are four main restrictions on creating a vector in R. We must remember these restrictions while creating any type of vector −
A vector name cannot have % sign.
A vector name cannot start with a number.
A vector can start with a dot but it should not have a number after it.
A vector cannot start with underscore.
Examples
Vectors with % sign −
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"
Vectors starting with a number −
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"
Vectors starting with a dot −
.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"
Vectors starting with underscore −
_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 "_"
Advertisements
